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
d3b8d56e
Commit
d3b8d56e
authored
Oct 20, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/decoding_encoding: prefer 'frame' over 'picture' for an AVFrame
Decrease confusion.
parent
dd84efe3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
decoding_encoding.c
doc/examples/decoding_encoding.c
+19
-19
No files found.
doc/examples/decoding_encoding.c
View file @
d3b8d56e
...
@@ -491,9 +491,9 @@ static void video_decode_example(const char *outfilename, const char *filename)
...
@@ -491,9 +491,9 @@ static void video_decode_example(const char *outfilename, const char *filename)
{
{
AVCodec
*
codec
;
AVCodec
*
codec
;
AVCodecContext
*
c
=
NULL
;
AVCodecContext
*
c
=
NULL
;
int
frame
,
got_pictur
e
,
len
;
int
frame
_count
,
got_fram
e
,
len
;
FILE
*
f
;
FILE
*
f
;
AVFrame
*
pictur
e
;
AVFrame
*
fram
e
;
uint8_t
inbuf
[
INBUF_SIZE
+
FF_INPUT_BUFFER_PADDING_SIZE
];
uint8_t
inbuf
[
INBUF_SIZE
+
FF_INPUT_BUFFER_PADDING_SIZE
];
char
buf
[
1024
];
char
buf
[
1024
];
AVPacket
avpkt
;
AVPacket
avpkt
;
...
@@ -537,13 +537,13 @@ static void video_decode_example(const char *outfilename, const char *filename)
...
@@ -537,13 +537,13 @@ static void video_decode_example(const char *outfilename, const char *filename)
exit
(
1
);
exit
(
1
);
}
}
pictur
e
=
avcodec_alloc_frame
();
fram
e
=
avcodec_alloc_frame
();
if
(
!
pictur
e
)
{
if
(
!
fram
e
)
{
fprintf
(
stderr
,
"Could not allocate video frame
\n
"
);
fprintf
(
stderr
,
"Could not allocate video frame
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
frame
=
0
;
frame
_count
=
0
;
for
(;;)
{
for
(;;)
{
avpkt
.
size
=
fread
(
inbuf
,
1
,
INBUF_SIZE
,
f
);
avpkt
.
size
=
fread
(
inbuf
,
1
,
INBUF_SIZE
,
f
);
if
(
avpkt
.
size
==
0
)
if
(
avpkt
.
size
==
0
)
...
@@ -566,21 +566,21 @@ static void video_decode_example(const char *outfilename, const char *filename)
...
@@ -566,21 +566,21 @@ static void video_decode_example(const char *outfilename, const char *filename)
feed decoder and see if it could decode a frame */
feed decoder and see if it could decode a frame */
avpkt
.
data
=
inbuf
;
avpkt
.
data
=
inbuf
;
while
(
avpkt
.
size
>
0
)
{
while
(
avpkt
.
size
>
0
)
{
len
=
avcodec_decode_video2
(
c
,
picture
,
&
got_pictur
e
,
&
avpkt
);
len
=
avcodec_decode_video2
(
c
,
frame
,
&
got_fram
e
,
&
avpkt
);
if
(
len
<
0
)
{
if
(
len
<
0
)
{
fprintf
(
stderr
,
"Error while decoding frame %d
\n
"
,
frame
);
fprintf
(
stderr
,
"Error while decoding frame %d
\n
"
,
frame
_count
);
exit
(
1
);
exit
(
1
);
}
}
if
(
got_
pictur
e
)
{
if
(
got_
fram
e
)
{
printf
(
"Saving frame %3d
\n
"
,
frame
);
printf
(
"Saving frame %3d
\n
"
,
frame
_count
);
fflush
(
stdout
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
/* the picture is allocated by the decoder. no need to
free it */
free it */
snprintf
(
buf
,
sizeof
(
buf
),
outfilename
,
frame
);
snprintf
(
buf
,
sizeof
(
buf
),
outfilename
,
frame
_count
);
pgm_save
(
picture
->
data
[
0
],
pictur
e
->
linesize
[
0
],
pgm_save
(
frame
->
data
[
0
],
fram
e
->
linesize
[
0
],
c
->
width
,
c
->
height
,
buf
);
c
->
width
,
c
->
height
,
buf
);
frame
++
;
frame
_count
++
;
}
}
avpkt
.
size
-=
len
;
avpkt
.
size
-=
len
;
avpkt
.
data
+=
len
;
avpkt
.
data
+=
len
;
...
@@ -592,24 +592,24 @@ static void video_decode_example(const char *outfilename, const char *filename)
...
@@ -592,24 +592,24 @@ static void video_decode_example(const char *outfilename, const char *filename)
chance to get the last frame of the video */
chance to get the last frame of the video */
avpkt
.
data
=
NULL
;
avpkt
.
data
=
NULL
;
avpkt
.
size
=
0
;
avpkt
.
size
=
0
;
len
=
avcodec_decode_video2
(
c
,
picture
,
&
got_pictur
e
,
&
avpkt
);
len
=
avcodec_decode_video2
(
c
,
frame
,
&
got_fram
e
,
&
avpkt
);
if
(
got_
pictur
e
)
{
if
(
got_
fram
e
)
{
printf
(
"Saving last frame %3d
\n
"
,
frame
);
printf
(
"Saving last frame %3d
\n
"
,
frame
_count
);
fflush
(
stdout
);
fflush
(
stdout
);
/* the picture is allocated by the decoder. no need to
/* the picture is allocated by the decoder. no need to
free it */
free it */
snprintf
(
buf
,
sizeof
(
buf
),
outfilename
,
frame
);
snprintf
(
buf
,
sizeof
(
buf
),
outfilename
,
frame
_count
);
pgm_save
(
picture
->
data
[
0
],
pictur
e
->
linesize
[
0
],
pgm_save
(
frame
->
data
[
0
],
fram
e
->
linesize
[
0
],
c
->
width
,
c
->
height
,
buf
);
c
->
width
,
c
->
height
,
buf
);
frame
++
;
frame
_count
++
;
}
}
fclose
(
f
);
fclose
(
f
);
avcodec_close
(
c
);
avcodec_close
(
c
);
av_free
(
c
);
av_free
(
c
);
avcodec_free_frame
(
&
pictur
e
);
avcodec_free_frame
(
&
fram
e
);
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
...
...
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