]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vdpau_vc1.c
configure: Document --enable-libfontconfig
[ffmpeg] / libavcodec / vdpau_vc1.c
index 4d84cd26f1f9ebf52a291be157e5362dc9d2af00..4f87c52ecc99d4a5f2d33702480fe17065941a66 100644 (file)
@@ -32,9 +32,10 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
                                  const uint8_t *buffer, uint32_t size)
 {
     VC1Context * const v  = avctx->priv_data;
-    AVVDPAUContext *hwctx = avctx->hwaccel_context;
     MpegEncContext * const s = &v->s;
-    VdpPictureInfoVC1 *info = &hwctx->info.vc1;
+    Picture *pic          = s->current_picture_ptr;
+    struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
+    VdpPictureInfoVC1 *info = &pic_ctx->info.vc1;
     VdpVideoSurface ref;
 
     /*  fill LvPictureInfoVC1 struct */
@@ -43,12 +44,12 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
 
     switch (s->pict_type) {
     case AV_PICTURE_TYPE_B:
-        ref = ff_vdpau_get_surface_id(&s->next_picture);
+        ref = ff_vdpau_get_surface_id(s->next_picture.f);
         assert(ref != VDP_INVALID_HANDLE);
         info->backward_reference = ref;
         /* fall-through */
     case AV_PICTURE_TYPE_P:
-        ref = ff_vdpau_get_surface_id(&s->last_picture);
+        ref = ff_vdpau_get_surface_id(s->last_picture.f);
         assert(ref != VDP_INVALID_HANDLE);
         info->forward_reference  = ref;
     }
@@ -59,7 +60,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
     else
         info->picture_type  = s->pict_type - 1 + s->pict_type / 3;
 
-    info->frame_coding_mode = v->fcm;
+    info->frame_coding_mode = v->fcm ? (v->fcm + 1) : 0;
     info->postprocflag      = v->postprocflag;
     info->pulldown          = v->broadcast;
     info->interlace         = v->interlace;
@@ -82,29 +83,53 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
     info->range_mapuv       = v->range_mapuv;
     /* Specific to simple/main profile only */
     info->multires          = v->multires;
-    info->syncmarker        = v->s.resync_marker;
+    info->syncmarker        = v->resync_marker;
     info->rangered          = v->rangered | (v->rangeredfrm << 1);
     info->maxbframes        = v->s.max_b_frames;
     info->deblockEnable     = v->postprocflag & 1;
     info->pquant            = v->pq;
 
-    return ff_vdpau_common_start_frame(avctx, buffer, size);
+    return ff_vdpau_common_start_frame(pic_ctx, buffer, size);
 }
 
 static int vdpau_vc1_decode_slice(AVCodecContext *avctx,
                                   const uint8_t *buffer, uint32_t size)
 {
-    AVVDPAUContext *hwctx = avctx->hwaccel_context;
+    VC1Context * const v  = avctx->priv_data;
+    MpegEncContext * const s = &v->s;
+    Picture *pic          = s->current_picture_ptr;
+    struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;
     int val;
 
-    val = ff_vdpau_add_buffer(avctx, buffer, size);
+    val = ff_vdpau_add_buffer(pic_ctx, buffer, size);
     if (val < 0)
         return val;
 
-    hwctx->info.vc1.slice_count++;
+    pic_ctx->info.vc1.slice_count++;
     return 0;
 }
 
+static int vdpau_vc1_init(AVCodecContext *avctx)
+{
+    VdpDecoderProfile profile;
+
+    switch (avctx->profile) {
+    case FF_PROFILE_VC1_SIMPLE:
+        profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
+        break;
+    case FF_PROFILE_VC1_MAIN:
+        profile = VDP_DECODER_PROFILE_VC1_MAIN;
+        break;
+    case FF_PROFILE_VC1_ADVANCED:
+        profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
+        break;
+    default:
+        return AVERROR(ENOTSUP);
+    }
+
+    return ff_vdpau_common_init(avctx, profile, avctx->level);
+}
+
 #if CONFIG_WMV3_VDPAU_HWACCEL
 AVHWAccel ff_wmv3_vdpau_hwaccel = {
     .name           = "wm3_vdpau",
@@ -114,6 +139,10 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = {
     .start_frame    = vdpau_vc1_start_frame,
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
+    .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_vc1_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(VDPAUContext),
 };
 #endif
 
@@ -125,4 +154,8 @@ AVHWAccel ff_vc1_vdpau_hwaccel = {
     .start_frame    = vdpau_vc1_start_frame,
     .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
+    .frame_priv_data_size = sizeof(struct vdpau_picture_context),
+    .init           = vdpau_vc1_init,
+    .uninit         = ff_vdpau_common_uninit,
+    .priv_data_size = sizeof(VDPAUContext),
 };