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
8f66d46c
Commit
8f66d46c
authored
Dec 08, 2018
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec: add gif parser
parent
a2710252
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
193 additions
and
2 deletions
+193
-2
Changelog
Changelog
+1
-0
Makefile
libavcodec/Makefile
+1
-0
gif_parser.c
libavcodec/gif_parser.c
+188
-0
parsers.c
libavcodec/parsers.c
+1
-0
version.h
libavcodec/version.h
+2
-2
No files found.
Changelog
View file @
8f66d46c
...
@@ -10,6 +10,7 @@ version <next>:
...
@@ -10,6 +10,7 @@ version <next>:
- truehd_core bitstream filter
- truehd_core bitstream filter
- dhav demuxer
- dhav demuxer
- PCM-DVD encoder
- PCM-DVD encoder
- GIF parser
version 4.1:
version 4.1:
...
...
libavcodec/Makefile
View file @
8f66d46c
...
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
...
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
OBJS-$(CONFIG_FLAC_PARSER)
+=
flac_parser.o
flacdata.o
flac.o
\
OBJS-$(CONFIG_FLAC_PARSER)
+=
flac_parser.o
flacdata.o
flac.o
\
vorbis_data.o
vorbis_data.o
OBJS-$(CONFIG_G729_PARSER)
+=
g729_parser.o
OBJS-$(CONFIG_G729_PARSER)
+=
g729_parser.o
OBJS-$(CONFIG_GIF_PARSER)
+=
gif_parser.o
OBJS-$(CONFIG_GSM_PARSER)
+=
gsm_parser.o
OBJS-$(CONFIG_GSM_PARSER)
+=
gsm_parser.o
OBJS-$(CONFIG_H261_PARSER)
+=
h261_parser.o
OBJS-$(CONFIG_H261_PARSER)
+=
h261_parser.o
OBJS-$(CONFIG_H263_PARSER)
+=
h263_parser.o
OBJS-$(CONFIG_H263_PARSER)
+=
h263_parser.o
...
...
libavcodec/gif_parser.c
0 → 100644
View file @
8f66d46c
/*
* GIF parser
* Copyright (c) 2018 Paul B Mahol
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* GIF parser
*/
#include "libavutil/avassert.h"
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "gif.h"
#include "parser.h"
typedef
enum
GIFParseStates
{
GIF_HEADER
=
1
,
GIF_EXTENSION
,
GIF_EXTENSION_BLOCK
,
GIF_IMAGE
,
GIF_IMAGE_BLOCK
,
}
gif_states
;
typedef
struct
GIFParseContext
{
ParseContext
pc
;
unsigned
found_sig
;
int
found_start
;
int
found_end
;
int
index
;
int
state
;
int
gct_flag
;
int
gct_size
;
int
block_size
;
int
etype
;
int
delay
;
}
GIFParseContext
;
static
int
gif_find_frame_end
(
GIFParseContext
*
g
,
const
uint8_t
*
buf
,
int
buf_size
,
void
*
logctx
)
{
int
index
,
next
=
END_NOT_FOUND
;
for
(
index
=
0
;
index
<
buf_size
;
index
++
)
{
if
(
!
g
->
state
)
{
if
(
!
memcmp
(
buf
+
index
,
gif87a_sig
,
6
)
||
!
memcmp
(
buf
+
index
,
gif89a_sig
,
6
))
{
g
->
state
=
GIF_HEADER
;
g
->
found_sig
++
;
}
else
if
(
buf
[
index
]
==
GIF_EXTENSION_INTRODUCER
)
{
g
->
state
=
GIF_EXTENSION
;
g
->
found_start
=
1
;
}
else
if
(
buf
[
index
]
==
GIF_IMAGE_SEPARATOR
)
{
g
->
state
=
GIF_IMAGE
;
}
else
if
(
buf
[
index
]
==
GIF_TRAILER
)
{
g
->
state
=
0
;
g
->
found_end
=
1
;
g
->
found_sig
=
0
;
}
else
{
g
->
found_sig
=
0
;
}
}
if
(
g
->
state
==
GIF_HEADER
)
{
if
(
g
->
index
==
10
)
{
g
->
gct_flag
=
!!
(
buf
[
index
]
&
0x80
);
g
->
gct_size
=
3
*
(
1
<<
((
buf
[
index
]
&
0x07
)
+
1
));
}
if
(
g
->
index
>=
12
+
g
->
gct_flag
*
g
->
gct_size
)
{
g
->
state
=
0
;
g
->
index
=
0
;
g
->
gct_flag
=
0
;
g
->
gct_size
=
0
;
continue
;
}
g
->
index
++
;
}
else
if
(
g
->
state
==
GIF_EXTENSION
)
{
if
(
g
->
found_start
&&
g
->
found_end
&&
g
->
found_sig
)
{
next
=
index
;
g
->
found_start
=
0
;
g
->
found_end
=
0
;
g
->
index
=
0
;
g
->
gct_flag
=
0
;
g
->
gct_size
=
0
;
g
->
state
=
0
;
break
;
}
if
(
g
->
index
==
1
)
{
g
->
etype
=
buf
[
index
];
}
if
(
g
->
index
>=
2
)
{
g
->
block_size
=
buf
[
index
];
g
->
index
=
0
;
g
->
state
=
GIF_EXTENSION_BLOCK
;
continue
;
}
g
->
index
++
;
}
else
if
(
g
->
state
==
GIF_IMAGE_BLOCK
)
{
if
(
!
g
->
index
)
g
->
block_size
=
buf
[
index
];
if
(
g
->
index
>=
g
->
block_size
)
{
g
->
index
=
0
;
if
(
!
g
->
block_size
)
{
g
->
state
=
0
;
g
->
found_end
=
1
;
}
continue
;
}
g
->
index
++
;
}
else
if
(
g
->
state
==
GIF_EXTENSION_BLOCK
)
{
if
(
g
->
etype
==
GIF_GCE_EXT_LABEL
)
{
if
(
g
->
index
==
0
)
g
->
delay
=
0
;
if
(
g
->
index
>=
1
&&
g
->
index
<=
2
)
{
g
->
delay
|=
buf
[
index
]
<<
(
8
*
(
g
->
index
-
1
));
}
}
if
(
g
->
index
>=
g
->
block_size
)
{
g
->
block_size
=
buf
[
index
];
g
->
index
=
0
;
if
(
!
g
->
block_size
)
g
->
state
=
0
;
continue
;
}
g
->
index
++
;
}
else
if
(
g
->
state
==
GIF_IMAGE
)
{
if
(
g
->
index
==
8
)
{
g
->
gct_flag
=
!!
(
buf
[
index
]
&
0x80
);
g
->
gct_size
=
3
*
(
1
<<
((
buf
[
index
]
&
0x07
)
+
1
));
}
if
(
g
->
index
>=
10
+
g
->
gct_flag
*
g
->
gct_size
)
{
g
->
state
=
GIF_IMAGE_BLOCK
;
g
->
index
=
0
;
g
->
gct_flag
=
0
;
g
->
gct_size
=
0
;
continue
;
}
g
->
index
++
;
}
}
return
next
;
}
static
int
gif_parse
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
const
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
const
uint8_t
*
buf
,
int
buf_size
)
{
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
;
}
s
->
duration
=
g
->
delay
;
*
poutbuf
=
buf
;
*
poutbuf_size
=
buf_size
;
return
next
;
}
AVCodecParser
ff_gif_parser
=
{
.
codec_ids
=
{
AV_CODEC_ID_GIF
},
.
priv_data_size
=
sizeof
(
GIFParseContext
),
.
parser_parse
=
gif_parse
,
.
parser_close
=
ff_parse_close
,
};
libavcodec/parsers.c
View file @
8f66d46c
...
@@ -41,6 +41,7 @@ extern AVCodecParser ff_dvdsub_parser;
...
@@ -41,6 +41,7 @@ extern AVCodecParser ff_dvdsub_parser;
extern
AVCodecParser
ff_dvd_nav_parser
;
extern
AVCodecParser
ff_dvd_nav_parser
;
extern
AVCodecParser
ff_flac_parser
;
extern
AVCodecParser
ff_flac_parser
;
extern
AVCodecParser
ff_g729_parser
;
extern
AVCodecParser
ff_g729_parser
;
extern
AVCodecParser
ff_gif_parser
;
extern
AVCodecParser
ff_gsm_parser
;
extern
AVCodecParser
ff_gsm_parser
;
extern
AVCodecParser
ff_h261_parser
;
extern
AVCodecParser
ff_h261_parser
;
extern
AVCodecParser
ff_h263_parser
;
extern
AVCodecParser
ff_h263_parser
;
...
...
libavcodec/version.h
View file @
8f66d46c
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 4
1
#define LIBAVCODEC_VERSION_MINOR 4
2
#define LIBAVCODEC_VERSION_MICRO 10
3
#define LIBAVCODEC_VERSION_MICRO 10
0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
LIBAVCODEC_VERSION_MINOR, \
...
...
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