vdpau: don't assume Picture and H264Picture are the same
[ffmpeg.git] / libavcodec / vdpau_vc1.c
index 638c07a..01ad0ae 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 */
@@ -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,26 +83,29 @@ 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;
 }
 
@@ -112,8 +116,9 @@ AVHWAccel ff_wmv3_vdpau_hwaccel = {
     .id             = AV_CODEC_ID_WMV3,
     .pix_fmt        = AV_PIX_FMT_VDPAU,
     .start_frame    = vdpau_vc1_start_frame,
-    .end_frame      = ff_vdpau_common_end_frame,
+    .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
+    .priv_data_size = sizeof(struct vdpau_picture_context),
 };
 #endif
 
@@ -123,6 +128,7 @@ AVHWAccel ff_vc1_vdpau_hwaccel = {
     .id             = AV_CODEC_ID_VC1,
     .pix_fmt        = AV_PIX_FMT_VDPAU,
     .start_frame    = vdpau_vc1_start_frame,
-    .end_frame      = ff_vdpau_common_end_frame,
+    .end_frame      = ff_vdpau_mpeg_end_frame,
     .decode_slice   = vdpau_vc1_decode_slice,
+    .priv_data_size = sizeof(struct vdpau_picture_context),
 };