]> git.sesse.net Git - ffmpeg/blobdiff - ffplay.c
Pass codec pixel format list to get_format, if present, fix vdpau decoding
[ffmpeg] / ffplay.c
index 7b208480f0dead4a45a45a696e1a4ae9890c5abf..129cd28871030550da3febc9c5c820341a097c87 100644 (file)
--- a/ffplay.c
+++ b/ffplay.c
@@ -1592,7 +1592,7 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
         unsigned vshift = i == 0 ? 0 : av_pix_fmt_descriptors[ref->pic->format].log2_chroma_h;
 
         if (ref->data[i]) {
-        ref->data[i]    += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift);
+            ref->data[i]    += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift);
         }
         pic->data[i]     = ref->data[i];
         pic->linesize[i] = ref->linesize[i];
@@ -1600,6 +1600,7 @@ static int input_get_buffer(AVCodecContext *codec, AVFrame *pic)
     pic->opaque = ref;
     pic->age    = INT_MAX;
     pic->type   = FF_BUFFER_TYPE_USER;
+    pic->reordered_opaque = codec->reordered_opaque;
     return 0;
 }
 
@@ -1609,6 +1610,25 @@ static void input_release_buffer(AVCodecContext *codec, AVFrame *pic)
     avfilter_unref_pic(pic->opaque);
 }
 
+static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic)
+{
+    AVFilterPicRef *ref = pic->opaque;
+
+    if (pic->data[0] == NULL) {
+        pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
+        return codec->get_buffer(codec, pic);
+    }
+
+    if ((codec->width != ref->w) || (codec->height != ref->h) ||
+        (codec->pix_fmt != ref->pic->format)) {
+        av_log(codec, AV_LOG_ERROR, "Picture properties changed.\n");
+        return -1;
+    }
+
+    pic->reordered_opaque = codec->reordered_opaque;
+    return 0;
+}
+
 static int input_init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     FilterPriv *priv = ctx->priv;
@@ -1622,6 +1642,7 @@ static int input_init(AVFilterContext *ctx, const char *args, void *opaque)
         priv->use_dr1 = 1;
         codec->get_buffer     = input_get_buffer;
         codec->release_buffer = input_release_buffer;
+        codec->reget_buffer   = input_reget_buffer;
     }
 
     priv->frame = avcodec_alloc_frame();