Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
99f06236
Commit
99f06236
authored
20 years ago
by
Michael Niedermayer
Browse files
Options
Downloads
Patches
Plain Diff
pnm parser
Originally committed as revision 3675 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
ae214ac3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libavcodec/allcodecs.c
+1
-0
1 addition, 0 deletions
libavcodec/allcodecs.c
libavcodec/avcodec.h
+3
-2
3 additions, 2 deletions
libavcodec/avcodec.h
libavcodec/parser.c
+3
-1
3 additions, 1 deletion
libavcodec/parser.c
libavcodec/pnm.c
+96
-18
96 additions, 18 deletions
libavcodec/pnm.c
with
103 additions
and
21 deletions
libavcodec/allcodecs.c
+
1
−
0
View file @
99f06236
...
...
@@ -247,6 +247,7 @@ PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
av_register_codec_parser
(
&
h263_parser
);
av_register_codec_parser
(
&
h264_parser
);
av_register_codec_parser
(
&
mjpeg_parser
);
av_register_codec_parser
(
&
pnm_parser
);
av_register_codec_parser
(
&
mpegaudio_parser
);
#ifdef CONFIG_AC3
...
...
This diff is collapsed.
Click to expand it.
libavcodec/avcodec.h
+
3
−
2
View file @
99f06236
...
...
@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 473
0
#define LIBAVCODEC_BUILD 473
1
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
...
...
@@ -2152,7 +2152,7 @@ typedef struct AVCodecParserContext {
}
AVCodecParserContext
;
typedef
struct
AVCodecParser
{
int
codec_ids
[
3
];
/* several codec IDs are permitted */
int
codec_ids
[
5
];
/* several codec IDs are permitted */
int
priv_data_size
;
int
(
*
parser_init
)(
AVCodecParserContext
*
s
);
int
(
*
parser_parse
)(
AVCodecParserContext
*
s
,
...
...
@@ -2180,6 +2180,7 @@ extern AVCodecParser h261_parser;
extern
AVCodecParser
h263_parser
;
extern
AVCodecParser
h264_parser
;
extern
AVCodecParser
mjpeg_parser
;
extern
AVCodecParser
pnm_parser
;
extern
AVCodecParser
mpegaudio_parser
;
extern
AVCodecParser
ac3_parser
;
...
...
This diff is collapsed.
Click to expand it.
libavcodec/parser.c
+
3
−
1
View file @
99f06236
...
...
@@ -38,7 +38,9 @@ AVCodecParserContext *av_parser_init(int codec_id)
for
(
parser
=
av_first_parser
;
parser
!=
NULL
;
parser
=
parser
->
next
)
{
if
(
parser
->
codec_ids
[
0
]
==
codec_id
||
parser
->
codec_ids
[
1
]
==
codec_id
||
parser
->
codec_ids
[
2
]
==
codec_id
)
parser
->
codec_ids
[
2
]
==
codec_id
||
parser
->
codec_ids
[
3
]
==
codec_id
||
parser
->
codec_ids
[
4
]
==
codec_id
)
goto
found
;
}
return
NULL
;
...
...
This diff is collapsed.
Click to expand it.
libavcodec/pnm.c
+
96
−
18
View file @
99f06236
...
...
@@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include
"avcodec.h"
#include
"mpegvideo.h"
//only for ParseContext
typedef
struct
PNMContext
{
uint8_t
*
bytestream
;
...
...
@@ -65,25 +66,9 @@ static int common_init(AVCodecContext *avctx){
return
0
;
}
static
int
pnm_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
data_size
,
uint8_t
*
buf
,
int
buf_size
)
{
PNMContext
*
const
s
=
avctx
->
priv_data
;
AVFrame
*
picture
=
data
;
AVFrame
*
const
p
=
(
AVFrame
*
)
&
s
->
picture
;
int
i
,
n
,
linesize
,
h
;
static
int
pnm_decode_header
(
AVCodecContext
*
avctx
,
PNMContext
*
const
s
){
char
buf1
[
32
];
unsigned
char
*
ptr
;
/* special case for last picture */
if
(
buf_size
==
0
)
{
return
0
;
}
s
->
bytestream_start
=
s
->
bytestream
=
buf
;
s
->
bytestream_end
=
buf
+
buf_size
;
int
h
;
pnm_get
(
s
,
buf1
,
sizeof
(
buf1
));
if
(
!
strcmp
(
buf1
,
"P4"
))
{
...
...
@@ -120,6 +105,30 @@ static int pnm_decode_frame(AVCodecContext *avctx,
h
/=
3
;
avctx
->
height
=
h
;
}
return
0
;
}
static
int
pnm_decode_frame
(
AVCodecContext
*
avctx
,
void
*
data
,
int
*
data_size
,
uint8_t
*
buf
,
int
buf_size
)
{
PNMContext
*
const
s
=
avctx
->
priv_data
;
AVFrame
*
picture
=
data
;
AVFrame
*
const
p
=
(
AVFrame
*
)
&
s
->
picture
;
int
i
,
n
,
linesize
,
h
;
unsigned
char
*
ptr
;
/* special case for last picture */
if
(
buf_size
==
0
)
{
return
0
;
}
s
->
bytestream_start
=
s
->
bytestream
=
buf
;
s
->
bytestream_end
=
buf
+
buf_size
;
if
(
pnm_decode_header
(
avctx
,
s
)
<
0
)
return
h
;
if
(
p
->
data
[
0
])
avctx
->
release_buffer
(
avctx
,
p
);
...
...
@@ -492,6 +501,75 @@ static int pam_probe(AVProbeData *pd)
}
#endif
static
int
pnm_parse
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
uint8_t
**
poutbuf
,
int
*
poutbuf_size
,
const
uint8_t
*
buf
,
int
buf_size
)
{
ParseContext
*
pc
=
s
->
priv_data
;
PNMContext
pnmctx
;
int
next
;
for
(;
pc
->
overread
>
0
;
pc
->
overread
--
){
pc
->
buffer
[
pc
->
index
++
]
=
pc
->
buffer
[
pc
->
overread_index
++
];
}
retry:
if
(
pc
->
index
){
pnmctx
.
bytestream_start
=
pnmctx
.
bytestream
=
pc
->
buffer
;
pnmctx
.
bytestream_end
=
pc
->
buffer
+
pc
->
index
;
}
else
{
pnmctx
.
bytestream_start
=
pnmctx
.
bytestream
=
buf
;
pnmctx
.
bytestream_end
=
buf
+
buf_size
;
}
if
(
pnm_decode_header
(
avctx
,
&
pnmctx
)
<
0
){
if
(
pnmctx
.
bytestream
<
pnmctx
.
bytestream_end
){
if
(
pc
->
index
){
pc
->
index
=
0
;
}
else
{
buf
++
;
buf_size
--
;
}
goto
retry
;
}
#if 0
if(pc->index && pc->index*2 + FF_INPUT_BUFFER_PADDING_SIZE < pc->buffer_size && buf_size > pc->index){
memcpy(pc->buffer + pc->index, buf, pc->index);
pc->index += pc->index;
buf += pc->index;
buf_size -= pc->index;
goto retry;
}
#endif
next
=
END_NOT_FOUND
;
}
else
{
next
=
pnmctx
.
bytestream
-
pnmctx
.
bytestream_start
+
avpicture_get_size
(
avctx
->
pix_fmt
,
avctx
->
width
,
avctx
->
height
);
if
(
pnmctx
.
bytestream_start
!=
buf
)
next
-=
pc
->
index
;
if
(
next
>
buf_size
)
next
=
END_NOT_FOUND
;
}
if
(
ff_combine_frame
(
pc
,
next
,
(
uint8_t
**
)
&
buf
,
&
buf_size
)
<
0
){
*
poutbuf
=
NULL
;
*
poutbuf_size
=
0
;
return
buf_size
;
}
*
poutbuf
=
(
uint8_t
*
)
buf
;
*
poutbuf_size
=
buf_size
;
return
next
;
}
AVCodecParser
pnm_parser
=
{
{
CODEC_ID_PGM
,
CODEC_ID_PGMYUV
,
CODEC_ID_PPM
,
CODEC_ID_PBM
},
sizeof
(
ParseContext
),
NULL
,
pnm_parse
,
ff_parse_close
,
};
AVCodec
pgm_encoder
=
{
"pgm"
,
CODEC_TYPE_VIDEO
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment