Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
7e57adb4
Commit
7e57adb4
authored
Apr 18, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/gif: fix timing.
pkt->duration can not be used since the values are only based on frame rate.
parent
13478b27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
gif.c
libavformat/gif.c
+10
-13
gif
tests/ref/lavf/gif
+2
-2
No files found.
libavformat/gif.c
View file @
7e57adb4
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
*/
*/
#include "avformat.h"
#include "avformat.h"
#include "internal.h"
#include "libavutil/avassert.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/log.h"
...
@@ -67,6 +68,7 @@ static int gif_image_write_header(AVIOContext *pb, int width, int height,
...
@@ -67,6 +68,7 @@ static int gif_image_write_header(AVIOContext *pb, int width, int height,
typedef
struct
{
typedef
struct
{
AVClass
*
class
;
/** Class for private options. */
AVClass
*
class
;
/** Class for private options. */
int
loop
;
int
loop
;
int64_t
prev_pts
;
}
GIFContext
;
}
GIFContext
;
static
int
gif_write_header
(
AVFormatContext
*
s
)
static
int
gif_write_header
(
AVFormatContext
*
s
)
...
@@ -89,6 +91,7 @@ static int gif_write_header(AVFormatContext *s)
...
@@ -89,6 +91,7 @@ static int gif_write_header(AVFormatContext *s)
width
=
video_enc
->
width
;
width
=
video_enc
->
width
;
height
=
video_enc
->
height
;
height
=
video_enc
->
height
;
avpriv_set_pts_info
(
s
->
streams
[
0
],
64
,
1
,
100
);
if
(
avpriv_set_systematic_pal2
(
palette
,
video_enc
->
pix_fmt
)
<
0
)
{
if
(
avpriv_set_systematic_pal2
(
palette
,
video_enc
->
pix_fmt
)
<
0
)
{
av_assert0
(
video_enc
->
pix_fmt
==
AV_PIX_FMT_PAL8
);
av_assert0
(
video_enc
->
pix_fmt
==
AV_PIX_FMT_PAL8
);
gif_image_write_header
(
pb
,
width
,
height
,
gif
->
loop
,
NULL
);
gif_image_write_header
(
pb
,
width
,
height
,
gif
->
loop
,
NULL
);
...
@@ -102,10 +105,9 @@ static int gif_write_header(AVFormatContext *s)
...
@@ -102,10 +105,9 @@ static int gif_write_header(AVFormatContext *s)
static
int
gif_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
static
int
gif_write_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
{
int
size
;
GIFContext
*
gif
=
s
->
priv_data
;
AVCodecContext
*
enc
=
s
->
streams
[
pkt
->
stream_index
]
->
codec
;
int
size
,
duration
;
AVIOContext
*
pb
=
s
->
pb
;
AVIOContext
*
pb
=
s
->
pb
;
int
jiffies
;
uint8_t
flags
=
0x4
,
transparent_color_index
=
0x1f
;
uint8_t
flags
=
0x4
,
transparent_color_index
=
0x1f
;
const
uint32_t
*
palette
;
const
uint32_t
*
palette
;
...
@@ -130,21 +132,15 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -130,21 +132,15 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
flags
|=
0x1
;
/* Transparent Color Flag */
flags
|=
0x1
;
/* Transparent Color Flag */
}
}
duration
=
pkt
->
pts
==
AV_NOPTS_VALUE
?
0
:
av_clip_uint16
(
pkt
->
pts
-
gif
->
prev_pts
);
gif
->
prev_pts
=
pkt
->
pts
;
/* graphic control extension block */
/* graphic control extension block */
avio_w8
(
pb
,
0x21
);
avio_w8
(
pb
,
0x21
);
avio_w8
(
pb
,
0xf9
);
avio_w8
(
pb
,
0xf9
);
avio_w8
(
pb
,
0x04
);
/* block size */
avio_w8
(
pb
,
0x04
);
/* block size */
avio_w8
(
pb
,
flags
);
avio_w8
(
pb
,
flags
);
avio_wl16
(
pb
,
duration
);
/* 1 jiffy is 1/70 s */
/* the delay_time field indicates the number of jiffies - 1 */
/* XXX: should use delay, in order to be more accurate */
/* instead of using the same rounded value each time */
/* XXX: don't even remember if I really use it for now */
jiffies
=
(
70
*
enc
->
time_base
.
num
/
enc
->
time_base
.
den
)
-
1
;
avio_wl16
(
pb
,
jiffies
);
avio_w8
(
pb
,
transparent_color_index
);
avio_w8
(
pb
,
transparent_color_index
);
avio_w8
(
pb
,
0x00
);
avio_w8
(
pb
,
0x00
);
...
@@ -189,4 +185,5 @@ AVOutputFormat ff_gif_muxer = {
...
@@ -189,4 +185,5 @@ AVOutputFormat ff_gif_muxer = {
.
write_packet
=
gif_write_packet
,
.
write_packet
=
gif_write_packet
,
.
write_trailer
=
gif_write_trailer
,
.
write_trailer
=
gif_write_trailer
,
.
priv_class
=
&
gif_muxer_class
,
.
priv_class
=
&
gif_muxer_class
,
.
flags
=
AVFMT_VARIABLE_FPS
,
};
};
tests/ref/lavf/gif
View file @
7e57adb4
66398be6fafa026fb0fa5f2978fa3446
*./tests/data/lavf/lavf.gif
c886d22859c033b2b0fe2d63ffcf8aef
*./tests/data/lavf/lavf.gif
2011766 ./tests/data/lavf/lavf.gif
2011766 ./tests/data/lavf/lavf.gif
./tests/data/lavf/lavf.gif CRC=0x
0d96deb8
./tests/data/lavf/lavf.gif CRC=0x
dca4429c
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment