Commit afd257b4 authored by Matthieu Bouron's avatar Matthieu Bouron

doc/examples/filtering_video: switch to new decoding API

parent b22c4d82
......@@ -213,7 +213,6 @@ int main(int argc, char **argv)
AVPacket packet;
AVFrame *frame = av_frame_alloc();
AVFrame *filt_frame = av_frame_alloc();
int got_frame;
if (!frame || !filt_frame) {
perror("Could not allocate frame");
......@@ -238,14 +237,22 @@ int main(int argc, char **argv)
break;
if (packet.stream_index == video_stream_index) {
got_frame = 0;
ret = avcodec_decode_video2(dec_ctx, frame, &got_frame, &packet);
ret = avcodec_send_packet(dec_ctx, &packet);
if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error decoding video\n");
av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
break;
}
if (got_frame) {
while (ret >= 0) {
ret = avcodec_receive_frame(dec_ctx, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
break;
} else if (ret < 0) {
av_log(NULL, AV_LOG_ERROR, "Error while receiving a frame from the decoder\n");
goto end;
}
if (ret >= 0) {
frame->pts = av_frame_get_best_effort_timestamp(frame);
/* push the decoded frame into the filtergraph */
......@@ -267,6 +274,7 @@ int main(int argc, char **argv)
av_frame_unref(frame);
}
}
}
av_packet_unref(&packet);
}
end:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment