[FFmpeg-devel] avfilter/src_movie: change the deprecate API to new decode api

Submitted by Steven Liu on March 23, 2019, 10:23 a.m.

Details

Message ID 20190323102303.25150-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu March 23, 2019, 10:23 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavfilter/src_movie.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index bcabfcc4c2..c313d714fe 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -172,8 +172,6 @@  static int open_stream(void *log, MovieStream *st)
     if (ret < 0)
         return ret;
 
-    st->codec_ctx->refcounted_frames = 1;
-
     if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) {
         av_log(log, AV_LOG_ERROR, "Failed to open codec\n");
         return ret;
@@ -524,17 +522,17 @@  static int movie_push_frame(AVFilterContext *ctx, unsigned out_id)
         return AVERROR(ENOMEM);
 
     frame_type = st->st->codecpar->codec_type;
-    switch (frame_type) {
-    case AVMEDIA_TYPE_VIDEO:
-        ret = avcodec_decode_video2(st->codec_ctx, frame, &got_frame, pkt);
-        break;
-    case AVMEDIA_TYPE_AUDIO:
-        ret = avcodec_decode_audio4(st->codec_ctx, frame, &got_frame, pkt);
-        break;
-    default:
+    if (frame_type == AVMEDIA_TYPE_VIDEO || frame_type == AVMEDIA_TYPE_AUDIO) {
+        ret = avcodec_send_packet(st->codec_ctx, pkt);
+        ret = avcodec_receive_frame(st->codec_ctx, frame);
+        if (ret >= 0)
+            got_frame = 1;
+        if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+            ret = 0;
+    } else {
         ret = AVERROR(ENOSYS);
-        break;
     }
+
     if (ret < 0) {
         av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret));
         av_frame_free(&frame);