From 8ea416f35de0c664ef47b71841756758f22d7faa Mon Sep 17 00:00:00 2001 From: Christian König Date: Wed, 4 Jan 2012 14:46:33 +0100 Subject: vl: move away from state like parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again based on Maartens work, but keep begin_frame and end_frame functions for now. Signed-off-by: Christian König --- src/gallium/state_trackers/vdpau/decode.c | 276 ++++++++++++------------- src/gallium/state_trackers/xorg/xvmc/surface.c | 46 ++--- 2 files changed, 150 insertions(+), 172 deletions(-) (limited to 'src/gallium/state_trackers') diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index ab7bf113fa6..2870dc419ac 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -162,66 +162,66 @@ vlVdpDecoderGetParameters(VdpDecoder decoder, return VDP_STATUS_OK; } +static VdpStatus +vlVdpGetReferenceFrame(VdpVideoSurface handle, struct pipe_video_buffer **ref_frame) +{ + vlVdpSurface *surface; + + /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ + if (handle == VDP_INVALID_HANDLE) { + *ref_frame = NULL; + return VDP_STATUS_OK; + } + + surface = vlGetDataHTAB(handle); + if (!surface) + return VDP_STATUS_INVALID_HANDLE; + + *ref_frame = surface->video_buffer; + if (!*ref_frame) + return VDP_STATUS_INVALID_HANDLE; + + return VDP_STATUS_OK; +} + /** * Decode a mpeg 1/2 video. */ static VdpStatus -vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder, +vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture, VdpPictureInfoMPEG1Or2 *picture_info) { - struct pipe_mpeg12_picture_desc picture; - struct pipe_mpeg12_quant_matrix quant; - struct pipe_video_buffer *ref_frames[2]; - unsigned i; + VdpStatus r; VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n"); - i = 0; - - /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ - if (picture_info->forward_reference != VDP_INVALID_HANDLE) { - ref_frames[i] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference))->video_buffer; - if (!ref_frames[i]) - return VDP_STATUS_INVALID_HANDLE; - ++i; - } - - if (picture_info->backward_reference != VDP_INVALID_HANDLE) { - ref_frames[i] = ((vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference))->video_buffer; - if (!ref_frames[i]) - return VDP_STATUS_INVALID_HANDLE; - ++i; - } + r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); + if (r != VDP_STATUS_OK) + return r; + + r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); + if (r != VDP_STATUS_OK) + return r; + + picture->picture_coding_type = picture_info->picture_coding_type; + picture->picture_structure = picture_info->picture_structure; + picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct; + picture->q_scale_type = picture_info->q_scale_type; + picture->alternate_scan = picture_info->alternate_scan; + picture->intra_vlc_format = picture_info->intra_vlc_format; + picture->concealment_motion_vectors = picture_info->concealment_motion_vectors; + picture->intra_dc_precision = picture_info->intra_dc_precision; + picture->f_code[0][0] = picture_info->f_code[0][0] - 1; + picture->f_code[0][1] = picture_info->f_code[0][1] - 1; + picture->f_code[1][0] = picture_info->f_code[1][0] - 1; + picture->f_code[1][1] = picture_info->f_code[1][1] - 1; + picture->num_slices = picture_info->slice_count; + picture->top_field_first = picture_info->top_field_first; + picture->full_pel_forward_vector = picture_info->full_pel_forward_vector; + picture->full_pel_backward_vector = picture_info->full_pel_backward_vector; + picture->intra_matrix = picture_info->intra_quantizer_matrix; + picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix; - decoder->set_reference_frames(decoder, ref_frames, i); - - memset(&picture, 0, sizeof(picture)); - picture.base.profile = decoder->profile; - picture.picture_coding_type = picture_info->picture_coding_type; - picture.picture_structure = picture_info->picture_structure; - picture.frame_pred_frame_dct = picture_info->frame_pred_frame_dct; - picture.q_scale_type = picture_info->q_scale_type; - picture.alternate_scan = picture_info->alternate_scan; - picture.intra_vlc_format = picture_info->intra_vlc_format; - picture.concealment_motion_vectors = picture_info->concealment_motion_vectors; - picture.intra_dc_precision = picture_info->intra_dc_precision; - picture.f_code[0][0] = picture_info->f_code[0][0] - 1; - picture.f_code[0][1] = picture_info->f_code[0][1] - 1; - picture.f_code[1][0] = picture_info->f_code[1][0] - 1; - picture.f_code[1][1] = picture_info->f_code[1][1] - 1; - picture.num_slices = picture_info->slice_count; - picture.top_field_first = picture_info->top_field_first; - picture.full_pel_forward_vector = picture_info->full_pel_forward_vector; - picture.full_pel_backward_vector = picture_info->full_pel_backward_vector; - - decoder->set_picture_parameters(decoder, &picture.base); - - memset(&quant, 0, sizeof(quant)); - quant.base.codec = PIPE_VIDEO_CODEC_MPEG12; - quant.intra_matrix = picture_info->intra_quantizer_matrix; - quant.non_intra_matrix = picture_info->non_intra_quantizer_matrix; - - decoder->set_quant_matrix(decoder, &quant.base); return VDP_STATUS_OK; } @@ -229,113 +229,90 @@ vlVdpDecoderRenderMpeg12(struct pipe_video_decoder *decoder, * Decode a mpeg 4 video. */ static VdpStatus -vlVdpDecoderRenderMpeg4(struct pipe_video_decoder *decoder, - VdpPictureInfoMPEG4Part2 *picture_info) +vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture, + VdpPictureInfoMPEG4Part2 *picture_info) { - struct pipe_mpeg4_picture_desc picture; - struct pipe_mpeg4_quant_matrix quant; - struct pipe_video_buffer *ref_frames[2] = {}; + VdpStatus r; unsigned i; VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\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; - } + r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); + if (r != VDP_STATUS_OK) + return r; - 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); + r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); + if (r != VDP_STATUS_OK) + return r; - memset(&picture, 0, sizeof(picture)); - picture.base.profile = decoder->profile; for (i = 0; i < 2; ++i) { - picture.trd[i] = picture_info->trd[i]; - picture.trb[i] = picture_info->trb[i]; + picture->trd[i] = picture_info->trd[i]; + picture->trb[i] = picture_info->trb[i]; } - picture.vop_time_increment_resolution = picture_info->vop_time_increment_resolution; - picture.vop_coding_type = picture_info->vop_coding_type; - picture.vop_fcode_forward = picture_info->vop_fcode_forward; - picture.vop_fcode_backward = picture_info->vop_fcode_backward; - picture.resync_marker_disable = picture_info->resync_marker_disable; - picture.interlaced = picture_info->interlaced; - picture.quant_type = picture_info->quant_type; - picture.quarter_sample = picture_info->quarter_sample; - picture.short_video_header = picture_info->short_video_header; - picture.rounding_control = picture_info->rounding_control; - picture.alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag; - picture.top_field_first = picture_info->top_field_first; - decoder->set_picture_parameters(decoder, &picture.base); - - memset(&quant, 0, sizeof(quant)); - quant.base.codec = PIPE_VIDEO_CODEC_MPEG4; - quant.intra_matrix = picture_info->intra_quantizer_matrix; - quant.non_intra_matrix = picture_info->non_intra_quantizer_matrix; - decoder->set_quant_matrix(decoder, &quant.base); + picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution; + picture->vop_coding_type = picture_info->vop_coding_type; + picture->vop_fcode_forward = picture_info->vop_fcode_forward; + picture->vop_fcode_backward = picture_info->vop_fcode_backward; + picture->resync_marker_disable = picture_info->resync_marker_disable; + picture->interlaced = picture_info->interlaced; + picture->quant_type = picture_info->quant_type; + picture->quarter_sample = picture_info->quarter_sample; + picture->short_video_header = picture_info->short_video_header; + picture->rounding_control = picture_info->rounding_control; + picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag; + picture->top_field_first = picture_info->top_field_first; + picture->intra_matrix = picture_info->intra_quantizer_matrix; + picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix; + return VDP_STATUS_OK; } static VdpStatus -vlVdpDecoderRenderVC1(struct pipe_video_decoder *decoder, +vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture, VdpPictureInfoVC1 *picture_info) { - struct pipe_vc1_picture_desc picture; - struct pipe_video_buffer *ref_frames[2] = {}; + VdpStatus r; 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; - } + r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); + if (r != VDP_STATUS_OK) + return r; + + r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); + if (r != VDP_STATUS_OK) + return r; + + 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; - 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; } @@ -356,6 +333,12 @@ vlVdpDecoderRender(VdpDecoder decoder, VdpStatus ret; struct pipe_video_decoder *dec; unsigned i; + union { + struct pipe_picture_desc base; + struct pipe_mpeg12_picture_desc mpeg12; + struct pipe_mpeg4_picture_desc mpeg4; + struct pipe_vc1_picture_desc vc1; + } desc; VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding\n"); @@ -378,17 +361,17 @@ vlVdpDecoderRender(VdpDecoder decoder, // TODO: Recreate decoder with correct chroma return VDP_STATUS_INVALID_CHROMA_TYPE; - dec->set_decode_target(dec, vlsurf->video_buffer); - + memset(&desc, 0, sizeof(desc)); + desc.base.profile = dec->profile; switch (u_reduce_video_profile(dec->profile)) { case PIPE_VIDEO_CODEC_MPEG12: - ret = vlVdpDecoderRenderMpeg12(dec, (VdpPictureInfoMPEG1Or2 *)picture_info); + ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info); break; case PIPE_VIDEO_CODEC_MPEG4: - ret = vlVdpDecoderRenderMpeg4(dec, (VdpPictureInfoMPEG4Part2 *)picture_info); + ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info); break; case PIPE_VIDEO_CODEC_VC1: - ret = vlVdpDecoderRenderVC1(dec, (VdpPictureInfoVC1 *)picture_info); + ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info); break; default: return VDP_STATUS_INVALID_DECODER_PROFILE; @@ -396,12 +379,13 @@ vlVdpDecoderRender(VdpDecoder decoder, if (ret != VDP_STATUS_OK) return ret; - dec->begin_frame(dec); for (i = 0; i < bitstream_buffer_count; ++i) { buffers[i] = bitstream_buffers[i].bitstream; sizes[i] = bitstream_buffers[i].bitstream_bytes; } - dec->decode_bitstream(dec, bitstream_buffer_count, buffers, sizes); - dec->end_frame(dec); + + dec->begin_frame(dec, vlsurf->video_buffer, &desc.base); + dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base, bitstream_buffer_count, buffers, sizes); + dec->end_frame(dec, vlsurf->video_buffer, &desc.base); return ret; } diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index ddc937c64c1..06a3eb963ad 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -97,35 +97,23 @@ MacroBlocksToPipe(XvMCContextPrivate *context, } static void -SetDecoderStatus(XvMCSurfacePrivate *surface) +GetPictureDescription(XvMCSurfacePrivate *surface, struct pipe_mpeg12_picture_desc *desc) { - struct pipe_video_decoder *decoder; - struct pipe_video_buffer *ref_frames[2]; - struct pipe_mpeg12_picture_desc desc = { { PIPE_VIDEO_PROFILE_MPEG1} }; - - XvMCContextPrivate *context_priv; - unsigned i, num_refs = 0; - desc.picture_structure = surface->picture_structure; - - assert(surface); - - context_priv = surface->context->privData; - decoder = context_priv->decoder; - - decoder->set_decode_target(decoder, surface->video_buffer); + assert(surface && desc); + memset(desc, 0, sizeof(*desc)); + desc->base.profile = PIPE_VIDEO_PROFILE_MPEG1; + desc->picture_structure = surface->picture_structure; for (i = 0; i < 2; ++i) { if (surface->ref[i]) { XvMCSurfacePrivate *ref = surface->ref[i]->privData; if (ref) - ref_frames[num_refs++] = ref->video_buffer; + desc->ref[num_refs++] = ref->video_buffer; } } - decoder->set_reference_frames(decoder, ref_frames, num_refs); - decoder->set_picture_parameters(context_priv->decoder, &desc.base); } static void @@ -151,13 +139,14 @@ RecursiveEndFrame(XvMCSurfacePrivate *surface) } if (surface->picture_structure) { - SetDecoderStatus(surface); + struct pipe_mpeg12_picture_desc desc; + GetPictureDescription(surface, &desc); surface->picture_structure = 0; for (i = 0; i < 2; ++i) surface->ref[i] = NULL; - context_priv->decoder->end_frame(context_priv->decoder); + context_priv->decoder->end_frame(context_priv->decoder, surface->video_buffer, &desc.base); } } @@ -217,6 +206,7 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur { struct pipe_mpeg12_macroblock mb[num_macroblocks]; struct pipe_video_decoder *decoder; + struct pipe_mpeg12_picture_desc desc; XvMCContextPrivate *context_priv; XvMCSurfacePrivate *target_surface_priv; @@ -289,17 +279,20 @@ Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int pictur target_surface_priv->ref[1] = future_surface; if (target_surface_priv->picture_structure) - SetDecoderStatus(target_surface_priv); + GetPictureDescription(target_surface_priv, &desc); else { target_surface_priv->picture_structure = picture_structure; - SetDecoderStatus(target_surface_priv); - decoder->begin_frame(decoder); + GetPictureDescription(target_surface_priv, &desc); + decoder->begin_frame(decoder, target_surface_priv->video_buffer, &desc.base); } MacroBlocksToPipe(context_priv, target_surface_priv, picture_structure, xvmc_mb, blocks, mb, num_macroblocks); - context_priv->decoder->decode_macroblock(context_priv->decoder, &mb[0].base, num_macroblocks); + context_priv->decoder->decode_macroblock(context_priv->decoder, + target_surface_priv->video_buffer, + &desc.base, + &mb[0].base, num_macroblocks); XVMC_MSG(XVMC_TRACE, "[XvMC] Submitted surface %p for rendering.\n", target_surface); @@ -499,8 +492,9 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface) context_priv = surface_priv->context->privData; if (surface_priv->picture_structure) { - SetDecoderStatus(surface_priv); - context_priv->decoder->end_frame(context_priv->decoder); + struct pipe_mpeg12_picture_desc desc; + GetPictureDescription(surface_priv, &desc); + context_priv->decoder->end_frame(context_priv->decoder, surface_priv->video_buffer, &desc.base); } surface_priv->video_buffer->destroy(surface_priv->video_buffer); FREE(surface_priv); -- cgit v1.2.3