Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
6fd99e78
Commit
6fd99e78
authored
Dec 12, 2013
by
Peter Holik
Committed by
Vittorio Giovara
Dec 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
png: add a standalone parser
Useful for reading png images from a pipe.
parent
0d882e9e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
2 deletions
+129
-2
Changelog
Changelog
+1
-0
Makefile
libavcodec/Makefile
+1
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
png_parser.c
libavcodec/png_parser.c
+124
-0
version.h
libavcodec/version.h
+2
-2
No files found.
Changelog
View file @
6fd99e78
...
@@ -51,6 +51,7 @@ version 10:
...
@@ -51,6 +51,7 @@ version 10:
- support for decoding through VDPAU in avconv (the -hwaccel option)
- support for decoding through VDPAU in avconv (the -hwaccel option)
- remove mp3_header_(de)compress bitstream filters
- remove mp3_header_(de)compress bitstream filters
- stereoscopic 3d metadata handling
- stereoscopic 3d metadata handling
- png standalone parser
version 9:
version 9:
...
...
libavcodec/Makefile
View file @
6fd99e78
...
@@ -649,6 +649,7 @@ OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o \
...
@@ -649,6 +649,7 @@ OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o \
mpegaudiodecheader.o
mpegaudiodata.o
mpegaudiodecheader.o
mpegaudiodata.o
OBJS-$(CONFIG_MPEGVIDEO_PARSER)
+=
mpegvideo_parser.o
\
OBJS-$(CONFIG_MPEGVIDEO_PARSER)
+=
mpegvideo_parser.o
\
mpeg12.o
mpeg12data.o
mpeg12.o
mpeg12data.o
OBJS-$(CONFIG_PNG_PARSER)
+=
png_parser.o
OBJS-$(CONFIG_PNM_PARSER)
+=
pnm_parser.o
pnm.o
OBJS-$(CONFIG_PNM_PARSER)
+=
pnm_parser.o
pnm.o
OBJS-$(CONFIG_RV30_PARSER)
+=
rv34_parser.o
OBJS-$(CONFIG_RV30_PARSER)
+=
rv34_parser.o
OBJS-$(CONFIG_RV40_PARSER)
+=
rv34_parser.o
OBJS-$(CONFIG_RV40_PARSER)
+=
rv34_parser.o
...
...
libavcodec/allcodecs.c
View file @
6fd99e78
...
@@ -464,6 +464,7 @@ void avcodec_register_all(void)
...
@@ -464,6 +464,7 @@ void avcodec_register_all(void)
REGISTER_PARSER
(
MPEG4VIDEO
,
mpeg4video
);
REGISTER_PARSER
(
MPEG4VIDEO
,
mpeg4video
);
REGISTER_PARSER
(
MPEGAUDIO
,
mpegaudio
);
REGISTER_PARSER
(
MPEGAUDIO
,
mpegaudio
);
REGISTER_PARSER
(
MPEGVIDEO
,
mpegvideo
);
REGISTER_PARSER
(
MPEGVIDEO
,
mpegvideo
);
REGISTER_PARSER
(
PNG
,
png
);
REGISTER_PARSER
(
PNM
,
pnm
);
REGISTER_PARSER
(
PNM
,
pnm
);
REGISTER_PARSER
(
RV30
,
rv30
);
REGISTER_PARSER
(
RV30
,
rv30
);
REGISTER_PARSER
(
RV40
,
rv40
);
REGISTER_PARSER
(
RV40
,
rv40
);
...
...
libavcodec/png_parser.c
0 → 100644
View file @
6fd99e78
/*
* PNG parser
* Copyright (c) 2009 Peter Holik
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* PNG parser
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/common.h"
#include "parser.h"
#define PNG_SIGNATURE UINT64_C(0x89504e470d0a1a0a)
#define MNG_SIGNATURE UINT64_C(0x8a4d4e470d0a1a0a)
typedef
struct
PNGParseContext
{
ParseContext
pc
;
int
chunk_pos
;
///< position inside current chunk
int
chunk_length
;
///< length of the current chunk
int
remaining_size
;
///< remaining size of the current chunk
}
PNGParseContext
;
static
int
png_parse
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
const
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
const
uint8_t
*
buf
,
int
buf_size
)
{
PNGParseContext
*
ppc
=
s
->
priv_data
;
int
next
=
END_NOT_FOUND
;
int
i
=
0
;
*
poutbuf_size
=
0
;
if
(
buf_size
==
0
)
return
0
;
if
(
!
ppc
->
pc
.
frame_start_found
)
{
uint64_t
state64
=
ppc
->
pc
.
state64
;
for
(;
i
<
buf_size
;
i
++
)
{
state64
=
(
state64
<<
8
)
|
buf
[
i
];
if
(
state64
==
PNG_SIGNATURE
||
state64
==
MNG_SIGNATURE
)
{
i
++
;
ppc
->
pc
.
frame_start_found
=
1
;
break
;
}
}
ppc
->
pc
.
state64
=
state64
;
}
else
if
(
ppc
->
remaining_size
)
{
i
=
FFMIN
(
ppc
->
remaining_size
,
buf_size
);
ppc
->
remaining_size
-=
i
;
if
(
ppc
->
remaining_size
)
goto
flush
;
if
(
ppc
->
chunk_pos
==
-
1
)
{
next
=
i
;
goto
flush
;
}
}
for
(;
ppc
->
pc
.
frame_start_found
&&
i
<
buf_size
;
i
++
)
{
ppc
->
pc
.
state
=
(
ppc
->
pc
.
state
<<
8
)
|
buf
[
i
];
if
(
ppc
->
chunk_pos
==
3
)
{
ppc
->
chunk_length
=
AV_RL32
(
&
ppc
->
pc
.
state
);
if
(
ppc
->
chunk_length
>
0x7fffffff
)
{
ppc
->
chunk_pos
=
ppc
->
pc
.
frame_start_found
=
0
;
goto
flush
;
}
ppc
->
chunk_length
+=
4
;
}
else
if
(
ppc
->
chunk_pos
==
7
)
{
if
(
ppc
->
chunk_length
>=
buf_size
-
i
)
ppc
->
remaining_size
=
ppc
->
chunk_length
-
buf_size
+
i
+
1
;
if
(
AV_RB32
(
&
ppc
->
pc
.
state
)
==
MKTAG
(
'I'
,
'E'
,
'N'
,
'D'
))
{
if
(
ppc
->
remaining_size
)
ppc
->
chunk_pos
=
-
1
;
else
next
=
ppc
->
chunk_length
+
i
+
1
;
break
;
}
else
{
ppc
->
chunk_pos
=
0
;
if
(
ppc
->
remaining_size
)
break
;
else
i
+=
ppc
->
chunk_length
;
continue
;
}
}
ppc
->
chunk_pos
++
;
}
flush:
if
(
ff_combine_frame
(
&
ppc
->
pc
,
next
,
&
buf
,
&
buf_size
)
<
0
)
return
buf_size
;
ppc
->
chunk_pos
=
ppc
->
pc
.
frame_start_found
=
0
;
*
poutbuf
=
buf
;
*
poutbuf_size
=
buf_size
;
return
next
;
}
AVCodecParser
ff_png_parser
=
{
.
codec_ids
=
{
AV_CODEC_ID_PNG
},
.
priv_data_size
=
sizeof
(
PNGParseContext
),
.
parser_parse
=
png_parse
,
.
parser_close
=
ff_parse_close
,
};
libavcodec/version.h
View file @
6fd99e78
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
*/
*/
#define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 2
8
#define LIBAVCODEC_VERSION_MINOR 2
9
#define LIBAVCODEC_VERSION_MICRO
1
#define LIBAVCODEC_VERSION_MICRO
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