state_trackers/vdpau: Add support for VC-1 decoding
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Mon, 31 Oct 2011 17:37:37 +0000 (18:37 +0100)
committerChristian König <deathsimple@vodafone.de>
Thu, 3 Nov 2011 12:52:01 +0000 (13:52 +0100)
Add a struct with all the fields.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/vdpau/decode.c
src/gallium/state_trackers/vdpau/vdpau_private.h

index 0530b4a21adf358e12d6107b31266f6f49eb99c3..1940bf12ba1c8a8fdaf6436b5a56f1aaabdcf02c 100644 (file)
@@ -212,6 +212,40 @@ struct pipe_mpeg4_quant_matrix
    const uint8_t *non_intra_matrix;
 };
 
+struct pipe_vc1_picture_desc
+{
+   struct pipe_picture_desc base;
+   uint32_t slice_count;
+   uint8_t picture_type;
+   uint8_t frame_coding_mode;
+   uint8_t postprocflag;
+   uint8_t pulldown;
+   uint8_t interlace;
+   uint8_t tfcntrflag;
+   uint8_t finterpflag;
+   uint8_t psf;
+   uint8_t dquant;
+   uint8_t panscan_flag;
+   uint8_t refdist_flag;
+   uint8_t quantizer;
+   uint8_t extended_mv;
+   uint8_t extended_dmv;
+   uint8_t overlap;
+   uint8_t vstransform;
+   uint8_t loopfilter;
+   uint8_t fastuvmc;
+   uint8_t range_mapy_flag;
+   uint8_t range_mapy;
+   uint8_t range_mapuv_flag;
+   uint8_t range_mapuv;
+   uint8_t multires;
+   uint8_t syncmarker;
+   uint8_t rangered;
+   uint8_t maxbframes;
+   uint8_t deblockEnable;
+   uint8_t pquant;
+};
+
 #ifdef __cplusplus
 }
 #endif
index c39c365cc8d867b16b47c76bef703eabb0aabe97..f1351298fa177a2c7fb085e29f208e22fc641e18 100644 (file)
@@ -258,7 +258,7 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder,
 }
 
 /**
- * Decode a mpeg 1/2 video.
+ * Decode a mpeg 4 video.
  */
 static VdpStatus
 vlVdpDecoderRenderMpeg4(struct pipe_video_decoder *decoder,
@@ -313,6 +313,65 @@ vlVdpDecoderRenderMpeg4(struct pipe_video_decoder *decoder,
    return VDP_STATUS_OK;
 }
 
+static VdpStatus
+vlVdpDecoderRenderVC1(struct pipe_video_decoder *decoder,
+                      VdpPictureInfoVC1 *picture_info)
+{
+   struct pipe_vc1_picture_desc picture;
+   struct pipe_video_buffer *ref_frames[2] = {};
+   unsigned i;
+
+   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n");
+
+   /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
+   if (picture_info->forward_reference !=  VDP_INVALID_HANDLE) {
+      ref_frames[0] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer;
+      if (!ref_frames[0])
+         return VDP_STATUS_INVALID_HANDLE;
+   }
+
+   if (picture_info->backward_reference !=  VDP_INVALID_HANDLE) {
+      ref_frames[1] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer;
+      if (!ref_frames[1])
+         return VDP_STATUS_INVALID_HANDLE;
+   }
+   decoder->set_reference_frames(decoder, ref_frames, 2);
+
+   memset(&picture, 0, sizeof(picture));
+   picture.base.profile = decoder->profile;
+   picture.slice_count = picture_info->slice_count;
+   picture.picture_type = picture_info->picture_type;
+   picture.frame_coding_mode = picture_info->frame_coding_mode;
+   picture.postprocflag = picture_info->postprocflag;
+   picture.pulldown = picture_info->pulldown;
+   picture.interlace = picture_info->interlace;
+   picture.tfcntrflag = picture_info->tfcntrflag;
+   picture.finterpflag = picture_info->finterpflag;
+   picture.psf = picture_info->psf;
+   picture.dquant = picture_info->dquant;
+   picture.panscan_flag = picture_info->panscan_flag;
+   picture.refdist_flag = picture_info->refdist_flag;
+   picture.quantizer = picture_info->quantizer;
+   picture.extended_mv = picture_info->extended_mv;
+   picture.extended_dmv = picture_info->extended_dmv;
+   picture.overlap = picture_info->overlap;
+   picture.vstransform = picture_info->vstransform;
+   picture.loopfilter = picture_info->loopfilter;
+   picture.fastuvmc = picture_info->fastuvmc;
+   picture.range_mapy_flag = picture_info->range_mapy_flag;
+   picture.range_mapy = picture_info->range_mapy;
+   picture.range_mapuv_flag = picture_info->range_mapuv_flag;
+   picture.range_mapuv = picture_info->range_mapuv;
+   picture.multires = picture_info->multires;
+   picture.syncmarker = picture_info->syncmarker;
+   picture.rangered = picture_info->rangered;
+   picture.maxbframes = picture_info->maxbframes;
+   picture.deblockEnable = picture_info->deblockEnable;
+   picture.pquant = picture_info->pquant;
+   decoder->set_picture_parameters(decoder, &picture.base);
+   return VDP_STATUS_OK;
+}
+
 /**
  * Decode a compressed field/frame and render the result into a VdpVideoSurface.
  */
@@ -363,7 +422,9 @@ vlVdpDecoderRender(VdpDecoder decoder,
    case PIPE_VIDEO_CODEC_MPEG4:
       ret = vlVdpDecoderRenderMpeg4(dec, (VdpPictureInfoMPEG4Part2 *)picture_info);
       break;
-
+   case PIPE_VIDEO_CODEC_VC1:
+      ret = vlVdpDecoderRenderVC1(dec, (VdpPictureInfoVC1 *)picture_info);
+      break;
    default:
       return VDP_STATUS_INVALID_DECODER_PROFILE;
    }
index 04699a39ecc20238f2fac7040cda8de3d00a2cb5..aae6f7841a6d3cd6e7379670143453376a95fd5d 100644 (file)
@@ -224,6 +224,12 @@ ProfileToPipe(VdpDecoderProfile vdpau_profile)
          return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE;
       case VDP_DECODER_PROFILE_MPEG4_PART2_ASP:
          return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE;
+      case VDP_DECODER_PROFILE_VC1_SIMPLE:
+         return PIPE_VIDEO_PROFILE_VC1_SIMPLE;
+      case VDP_DECODER_PROFILE_VC1_MAIN:
+         return PIPE_VIDEO_PROFILE_VC1_MAIN;
+      case VDP_DECODER_PROFILE_VC1_ADVANCED:
+         return PIPE_VIDEO_PROFILE_VC1_ADVANCED;
       default:
          return PIPE_VIDEO_PROFILE_UNKNOWN;
    }
@@ -249,6 +255,12 @@ PipeToProfile(enum pipe_video_profile p_profile)
          return VDP_DECODER_PROFILE_MPEG4_PART2_SP;
       case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
          return VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
+      case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
+         return VDP_DECODER_PROFILE_VC1_SIMPLE;
+      case PIPE_VIDEO_PROFILE_VC1_MAIN:
+         return VDP_DECODER_PROFILE_VC1_MAIN;
+      case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
+         return VDP_DECODER_PROFILE_VC1_ADVANCED;
       default:
          assert(0);
          return -1;