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
44c9f374
Commit
44c9f374
authored
Oct 12, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/qsvdec: convert to the new decoding API
parent
1dd2b6c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
23 deletions
+25
-23
qsvdec.c
doc/examples/qsvdec.c
+25
-23
No files found.
doc/examples/qsvdec.c
View file @
44c9f374
...
...
@@ -92,41 +92,43 @@ static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx,
AVPacket
*
pkt
,
AVIOContext
*
output_ctx
)
{
int
ret
=
0
;
int
got_frame
=
1
;
while
(
pkt
->
size
>
0
||
(
!
pkt
->
data
&&
got_frame
))
{
ret
=
avcodec_decode_video2
(
decoder_ctx
,
frame
,
&
got_frame
,
pkt
);
if
(
ret
<
0
)
{
ret
=
avcodec_send_packet
(
decoder_ctx
,
pkt
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error during decoding
\n
"
);
return
ret
;
}
while
(
ret
>=
0
)
{
int
i
,
j
;
ret
=
avcodec_receive_frame
(
decoder_ctx
,
frame
);
if
(
ret
==
AVERROR
(
EAGAIN
)
||
ret
==
AVERROR_EOF
)
break
;
else
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error during decoding
\n
"
);
return
ret
;
}
pkt
->
data
+=
ret
;
pkt
->
size
-=
ret
;
/* A real program would do something useful with the decoded frame here.
* We just retrieve the raw data and write it to a file, which is rather
* useless but pedagogic. */
if
(
got_frame
)
{
int
i
,
j
;
ret
=
av_hwframe_transfer_data
(
sw_frame
,
frame
,
0
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error transferring the data to system memory
\n
"
);
goto
fail
;
}
ret
=
av_hwframe_transfer_data
(
sw_frame
,
frame
,
0
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error transferring the data to system memory
\n
"
);
goto
fail
;
}
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
sw_frame
->
data
)
&&
sw_frame
->
data
[
i
];
i
++
)
for
(
j
=
0
;
j
<
(
sw_frame
->
height
>>
(
i
>
0
));
j
++
)
avio_write
(
output_ctx
,
sw_frame
->
data
[
i
]
+
j
*
sw_frame
->
linesize
[
i
],
sw_frame
->
width
);
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
sw_frame
->
data
)
&&
sw_frame
->
data
[
i
];
i
++
)
for
(
j
=
0
;
j
<
(
sw_frame
->
height
>>
(
i
>
0
));
j
++
)
avio_write
(
output_ctx
,
sw_frame
->
data
[
i
]
+
j
*
sw_frame
->
linesize
[
i
],
sw_frame
->
width
);
fail:
av_frame_unref
(
sw_frame
);
av_frame_unref
(
frame
);
av_frame_unref
(
sw_frame
);
av_frame_unref
(
frame
);
if
(
ret
<
0
)
return
ret
;
}
if
(
ret
<
0
)
return
ret
;
}
return
0
;
...
...
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