]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vda_h264.c
codec_desc: Add missing DXV entry
[ffmpeg] / libavcodec / vda_h264.c
index c7f6a7432e9f4eb411598a8f1eb753984ad102ca..62ad5e9f8d0390271db64d0ff86ec332ba7bc6cb 100644 (file)
@@ -129,7 +129,7 @@ static int vda_old_h264_end_frame(AVCodecContext *avctx)
     H264Context *h                      = avctx->priv_data;
     VDAContext *vda                     = avctx->internal->hwaccel_priv_data;
     struct vda_context *vda_ctx         = avctx->hwaccel_context;
-    AVFrame *frame                      = &h->cur_pic_ptr->f;
+    AVFrame *frame                      = h->cur_pic_ptr->f;
     int status;
 
     if (!vda_ctx->decoder || !vda->bitstream)
@@ -325,7 +325,7 @@ static int vda_h264_end_frame(AVCodecContext *avctx)
     H264Context *h        = avctx->priv_data;
     VDAContext *vda       = avctx->internal->hwaccel_priv_data;
     AVVDAContext *vda_ctx = avctx->hwaccel_context;
-    AVFrame *frame        = &h->cur_pic_ptr->f;
+    AVFrame *frame        = h->cur_pic_ptr->f;
     uint32_t flush_flags  = 1 << 0; ///< kVDADecoderFlush_emitFrames
     CFDataRef coded_frame;
     OSStatus status;
@@ -345,24 +345,25 @@ static int vda_h264_end_frame(AVCodecContext *avctx)
 
     CFRelease(coded_frame);
 
+    if (!vda->frame)
+        return AVERROR_UNKNOWN;
+
     if (status != kVDADecoderNoErr) {
         av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status);
         return AVERROR_UNKNOWN;
     }
 
-    if (vda->frame) {
-        av_buffer_unref(&frame->buf[0]);
+    av_buffer_unref(&frame->buf[0]);
 
-        frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
-                                         sizeof(vda->frame),
-                                         release_buffer, NULL,
-                                         AV_BUFFER_FLAG_READONLY);
-        if (!frame->buf)
-            return AVERROR(ENOMEM);
+    frame->buf[0] = av_buffer_create((uint8_t*)vda->frame,
+                                     sizeof(vda->frame),
+                                     release_buffer, NULL,
+                                     AV_BUFFER_FLAG_READONLY);
+    if (!frame->buf[0])
+        return AVERROR(ENOMEM);
 
-        frame->data[3] = (uint8_t*)vda->frame;
-        vda->frame = NULL;
-    }
+    frame->data[3] = (uint8_t*)vda->frame;
+    vda->frame = NULL;
 
     return 0;
 }
@@ -379,7 +380,7 @@ int ff_vda_default_init(AVCodecContext *avctx)
     CFMutableDictionaryRef buffer_attributes;
     CFMutableDictionaryRef io_surface_properties;
     CFNumberRef cv_pix_fmt;
-    int32_t fmt = 'avc1', pix_fmt = kCVPixelFormatType_422YpCbCr8;
+    int32_t fmt = 'avc1', pix_fmt = vda_ctx->cv_pix_fmt_type;
 
     // kCVPixelFormatType_420YpCbCr8Planar;