From: Michael Varga Date: Thu, 23 Oct 2014 15:13:05 +0000 (-0500) Subject: st/va: MPEG4 populate the PPS structure X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9f1ee1b5c941422ae4761388b9562f4abd67c461;p=mesa.git st/va: MPEG4 populate the PPS structure Signed-off-by: Michael Varga --- diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 8775681bb42..a4eb26b406b 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -80,6 +80,12 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * VAPictureParameterBufferMPEG2 *mpeg2; VAPictureParameterBufferH264 *h264; VAPictureParameterBufferVC1 * vc1; + VAPictureParameterBufferMPEG4 *mpeg4; + vlVaSurface *surf_forward; + vlVaSurface *surf_backward; + unsigned int i; + static const uint8_t default_intra_quant_matrix[64] = { 0 }; + static const uint8_t default_non_intra_quant_matrix[64] = { 0 }; switch (u_reduce_video_profile(context->decoder->profile)) { case PIPE_VIDEO_FORMAT_MPEG12: @@ -214,6 +220,72 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * context->desc.vc1.pquant = vc1->pic_quantizer_fields.bits.pic_quantizer_scale; break; + case PIPE_VIDEO_FORMAT_MPEG4: + assert(buf->size >= sizeof(VAPictureParameterBufferMPEG4) && buf->num_elements == 1); + mpeg4 = buf->data; + + context->mpeg4.pps = *mpeg4; + + /* vop_width */ + /* vop_height */ + /* forward_reference_picture */ + /* backward_reference_picture */ + context->desc.mpeg4.short_video_header = + mpeg4->vol_fields.bits.short_video_header; + /* chroma_format */ + context->desc.mpeg4.interlaced = mpeg4->vol_fields.bits.interlaced; + /* obmc_disable */ + /* sprite_enable */ + /* sprite_warping_accuracy */ + context->desc.mpeg4.quant_type = mpeg4->vol_fields.bits.quant_type; + context->desc.mpeg4.quarter_sample = mpeg4->vol_fields.bits.quarter_sample; + /* data_partitioned */ + /* reversible_vlc */ + context->desc.mpeg4.resync_marker_disable = + mpeg4->vol_fields.bits.resync_marker_disable; + /* no_of_sprite_warping_points */ + /* sprite_trajectory_du */ + /* sprite_trajectory_dv */ + /* quant_precision */ + context->desc.mpeg4.vop_coding_type = mpeg4->vop_fields.bits.vop_coding_type; + /* backward_reference_vop_coding_type */ + /* vop_rounding_type */ + /* intra_dc_vlc_thr */ + context->desc.mpeg4.top_field_first = + mpeg4->vop_fields.bits.top_field_first; + context->desc.mpeg4.alternate_vertical_scan_flag = + mpeg4->vop_fields.bits.alternate_vertical_scan_flag; + context->desc.mpeg4.vop_fcode_forward = mpeg4->vop_fcode_forward; + context->desc.mpeg4.vop_fcode_backward = mpeg4->vop_fcode_backward; + context->desc.mpeg4.vop_time_increment_resolution = + mpeg4->vop_time_increment_resolution; + /* num_gobs_in_vop */ + /* num_macroblocks_in_gob */ + context->desc.mpeg4.trb[0] = mpeg4->TRB; + context->desc.mpeg4.trb[1] = mpeg4->TRB; + context->desc.mpeg4.trd[0] = mpeg4->TRD; + context->desc.mpeg4.trd[1] = mpeg4->TRD; + + /* default [non-]intra quant matrix because mpv does not set these + matrices */ + if (!context->desc.mpeg4.intra_matrix) + context->desc.mpeg4.intra_matrix = default_intra_quant_matrix; + if (!context->desc.mpeg4.non_intra_matrix) + context->desc.mpeg4.non_intra_matrix = default_non_intra_quant_matrix; + + surf_forward = handle_table_get(drv->htab, mpeg4->forward_reference_picture); + if (surf_forward) + context->desc.mpeg4.ref[0] = surf_forward->buffer; + surf_backward = handle_table_get(drv->htab, mpeg4->backward_reference_picture); + if (surf_backward) + context->desc.mpeg4.ref[1] = surf_backward->buffer; + + context->mpeg4.vti_bits = 0; + for (i = context->desc.mpeg4.vop_time_increment_resolution; i > 0; i /= 2) + ++context->mpeg4.vti_bits; + + break; + default: break; } diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h index 060a1faeb9c..7d2fc24ca71 100644 --- a/src/gallium/state_trackers/va/va_private.h +++ b/src/gallium/state_trackers/va/va_private.h @@ -162,6 +162,15 @@ typedef struct { struct pipe_vc1_picture_desc vc1; struct pipe_h264_picture_desc h264; } desc; + + struct { + unsigned long long int frame_num; + unsigned int start_code_size; + unsigned int vti_bits; + unsigned int quant_scale; + VAPictureParameterBufferMPEG4 pps; + uint8_t start_code[32]; + } mpeg4; } vlVaContext; typedef struct {