Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
d81b6cbd
Commit
d81b6cbd
authored
May 20, 2023
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/gif_parser: fix possible wrong splitting of frames
And properly signal keyframes.
parent
b6066ceb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
gif_parser.c
libavcodec/gif_parser.c
+22
-12
No files found.
libavcodec/gif_parser.c
View file @
d81b6cbd
...
...
@@ -24,9 +24,6 @@
* GIF parser
*/
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "gif.h"
#include "parser.h"
...
...
@@ -50,11 +47,13 @@ typedef struct GIFParseContext {
int
block_size
;
int
etype
;
int
delay
;
int
keyframe
;
}
GIFParseContext
;
static
int
gif_find_frame_end
(
GIFParseContext
*
g
,
const
uint8_t
*
buf
,
int
buf_size
,
void
*
logctx
)
{
ParseContext
*
pc
=
&
g
->
pc
;
int
index
,
next
=
END_NOT_FOUND
;
for
(
index
=
0
;
index
<
buf_size
;
index
++
)
{
...
...
@@ -63,9 +62,10 @@ static int gif_find_frame_end(GIFParseContext *g, const uint8_t *buf,
!
memcmp
(
buf
+
index
,
gif89a_sig
,
6
))
{
g
->
state
=
GIF_HEADER
;
g
->
found_sig
++
;
g
->
keyframe
=
1
;
}
else
if
(
buf
[
index
]
==
GIF_EXTENSION_INTRODUCER
)
{
g
->
state
=
GIF_EXTENSION
;
g
->
found_start
=
1
;
g
->
found_start
=
pc
->
frame_start_found
=
1
;
}
else
if
(
buf
[
index
]
==
GIF_IMAGE_SEPARATOR
)
{
g
->
state
=
GIF_IMAGE
;
}
else
if
(
buf
[
index
]
==
GIF_TRAILER
)
{
...
...
@@ -93,7 +93,7 @@ static int gif_find_frame_end(GIFParseContext *g, const uint8_t *buf,
}
else
if
(
g
->
state
==
GIF_EXTENSION
)
{
if
(
g
->
found_start
&&
g
->
found_end
&&
g
->
found_sig
)
{
next
=
index
;
g
->
found_start
=
0
;
g
->
found_start
=
pc
->
frame_start_found
=
0
;
g
->
found_end
=
0
;
g
->
index
=
0
;
g
->
gct_flag
=
0
;
...
...
@@ -140,7 +140,7 @@ static int gif_find_frame_end(GIFParseContext *g, const uint8_t *buf,
}
g
->
index
++
;
}
else
if
(
g
->
state
==
GIF_IMAGE
)
{
if
(
g
->
index
==
8
)
{
if
(
g
->
index
==
9
)
{
g
->
gct_flag
=
!!
(
buf
[
index
]
&
0x80
);
g
->
gct_size
=
3
*
(
1
<<
((
buf
[
index
]
&
0x07
)
+
1
));
}
...
...
@@ -165,14 +165,24 @@ static int gif_parse(AVCodecParserContext *s, AVCodecContext *avctx,
GIFParseContext
*
g
=
s
->
priv_data
;
int
next
;
next
=
gif_find_frame_end
(
g
,
buf
,
buf_size
,
avctx
);
if
(
ff_combine_frame
(
&
g
->
pc
,
next
,
&
buf
,
&
buf_size
)
<
0
)
{
*
poutbuf
=
NULL
;
*
poutbuf_size
=
0
;
return
buf_size
;
*
poutbuf_size
=
0
;
*
poutbuf
=
NULL
;
if
(
s
->
flags
&
PARSER_FLAG_COMPLETE_FRAMES
)
{
next
=
buf_size
;
}
else
{
next
=
gif_find_frame_end
(
g
,
buf
,
buf_size
,
avctx
);
if
(
ff_combine_frame
(
&
g
->
pc
,
next
,
&
buf
,
&
buf_size
)
<
0
)
{
*
poutbuf
=
NULL
;
*
poutbuf_size
=
0
;
return
buf_size
;
}
}
s
->
duration
=
g
->
delay
;
s
->
duration
=
g
->
delay
?
g
->
delay
:
10
;
s
->
key_frame
=
g
->
keyframe
;
s
->
pict_type
=
g
->
keyframe
?
AV_PICTURE_TYPE_I
:
AV_PICTURE_TYPE_P
;
g
->
keyframe
=
0
;
*
poutbuf
=
buf
;
*
poutbuf_size
=
buf_size
;
...
...
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