]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/decode.c
Merge commit 'f951837ce58e8588b175fb53a76fd453a81528ec'
[ffmpeg] / libavcodec / decode.c
index 44b874d4f817d2fe8f2b79e8b627c910cbc09526..7601d1608289a90e1547a296a9607deac561c9f4 100644 (file)
@@ -613,7 +613,6 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
     if (ret == AVERROR_EOF)
         avci->draining_done = 1;
 
-    /* free the per-frame decode data */
     if (!ret) {
         /* the only case where decode data is not set should be decoders
          * that do not call ff_get_buffer() */
@@ -631,10 +630,11 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
                 }
             }
         }
-
-        av_buffer_unref(&frame->private_ref);
     }
 
+    /* free the per-frame decode data */
+    av_buffer_unref(&frame->private_ref);
+
     return ret;
 }
 
@@ -1090,15 +1090,19 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en
     return fmt[0];
 }
 
-static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
+static AVHWAccel *find_hwaccel(AVCodecContext *avctx,
                                enum AVPixelFormat pix_fmt)
 {
     AVHWAccel *hwaccel = NULL;
+    const AVClass *av_class =
+        (avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS)
+        ? avctx->codec->priv_class : NULL;
 
-    while ((hwaccel = av_hwaccel_next(hwaccel)))
-        if (hwaccel->id == codec_id
+    while ((hwaccel = av_hwaccel_next(hwaccel))) {
+        if (hwaccel->decoder_class == av_class && hwaccel->id == avctx->codec_id
             && hwaccel->pix_fmt == pix_fmt)
             return hwaccel;
+    }
     return NULL;
 }
 
@@ -1106,12 +1110,12 @@ static int setup_hwaccel(AVCodecContext *avctx,
                          const enum AVPixelFormat fmt,
                          const char *name)
 {
-    AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt);
+    AVHWAccel *hwa = find_hwaccel(avctx, fmt);
     int ret        = 0;
 
     if (!hwa) {
         av_log(avctx, AV_LOG_ERROR,
-               "Could not find an AVHWAccel for the pixel format: %s",
+               "Could not find an AVHWAccel for the pixel format: %s\n",
                name);
         return AVERROR(ENOENT);
     }