From 7e66a5224ecda580ff42da73514464f19c7ac663 Mon Sep 17 00:00:00 2001 From: Emeric Grange Date: Sun, 20 May 2012 18:23:24 +0200 Subject: g3dvl/vp8: Sync with last git master, move back detection of start codes into bitstream buffers from the state tracker to the decoder Signed-off-by: Emeric Grange --- src/gallium/auxiliary/vl/vl_vp8_decoder.c | 21 ++++++++++++++- src/gallium/auxiliary/vl/vp8/vp8_decoder.c | 41 +++++++++++++++++------------- src/gallium/state_trackers/vdpau/decode.c | 39 +--------------------------- 3 files changed, 44 insertions(+), 57 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_vp8_decoder.c b/src/gallium/auxiliary/vl/vl_vp8_decoder.c index 626feefdce..07c6d8ebb6 100644 --- a/src/gallium/auxiliary/vl/vl_vp8_decoder.c +++ b/src/gallium/auxiliary/vl/vl_vp8_decoder.c @@ -207,11 +207,30 @@ vl_vp8_decode_bitstream(struct pipe_video_decoder *decoder, struct vl_vp8_buffer *buf; assert(dec && target && picture); - assert(num_buffers == 1); + assert(num_buffers < 3); buf = vl_vp8_get_decode_buffer(dec, target); assert(buf); + // Try and detect start_code from the first data buffer + if (num_buffers > 1) + { + const uint8_t *datab = (const uint8_t *)buffers[dec->current_buffer]; + + if ((sizes[dec->current_buffer] == 3) && + (datab[0] == 0x9D && datab[1] == 0x01 && datab[2] == 0x2A)) + { + // The start_code [0x9D012A] is present in a dedicated buffer + ++dec->current_buffer; + dec->current_buffer %= 4; + } + else + { + printf("[G3DVL] Error : First VP8 VDPAU bitstream buffer is invalid !\n"); + return; + } + } + // Start bitstream decoding //vl_vp8_bs_decode(&buf->bs, target, desc, num_buffers, buffers, sizes); diff --git a/src/gallium/auxiliary/vl/vp8/vp8_decoder.c b/src/gallium/auxiliary/vl/vp8/vp8_decoder.c index 4aff049dd6..8a54ab4166 100644 --- a/src/gallium/auxiliary/vl/vp8/vp8_decoder.c +++ b/src/gallium/auxiliary/vl/vp8/vp8_decoder.c @@ -140,33 +140,37 @@ int vp8_decoder_start(VP8_COMMON *common, const unsigned char *data, unsigned data_size) { int retcode = 0; + int bitstreambuffer_offset = 0; - common->error.error_code = VPX_CODEC_OK; - - { - common->data = data; - common->data_size = data_size; + if (frame_header->key_frame == 0) + bitstreambuffer_offset = 10; + else + bitstreambuffer_offset = 3; - common->new_fb_idx = get_free_fb(common); + common->data = data + bitstreambuffer_offset; + common->data_size = data_size - bitstreambuffer_offset; + common->new_fb_idx = get_free_fb(common); - if (setjmp(common->error.jmp)) - { - common->error.setjmp = 0; + common->error.error_code = VPX_CODEC_OK; - /* We do not know if the missing frame(s) was supposed to update - * any of the reference buffers, but we act conservative and - * mark only the last buffer as corrupted. */ - common->yv12_fb[common->lst_fb_idx].corrupted = 1; + if (setjmp(common->error.jmp)) + { + common->error.setjmp = 0; - if (common->fb_idx_ref_cnt[common->new_fb_idx] > 0) - common->fb_idx_ref_cnt[common->new_fb_idx]--; + /* We do not know if the missing frame(s) was supposed to update + * any of the reference buffers, but we act conservative and + * mark only the last buffer as corrupted. */ + common->yv12_fb[common->lst_fb_idx].corrupted = 1; - return -1; - } + if (common->fb_idx_ref_cnt[common->new_fb_idx] > 0) + common->fb_idx_ref_cnt[common->new_fb_idx]--; - common->error.setjmp = 1; + return -1; } + common->error.setjmp = 1; + + // Frame decoding retcode = vp8_frame_decode(common, frame_header); if (retcode < 0) @@ -179,6 +183,7 @@ int vp8_decoder_start(VP8_COMMON *common, return retcode; } + // Software frame buffer handling { if (swap_frame_buffers(common)) { diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c index e9833b6c4c..7a51196c87 100644 --- a/src/gallium/state_trackers/vdpau/decode.c +++ b/src/gallium/state_trackers/vdpau/decode.c @@ -462,7 +462,7 @@ vlVdpDecoderRender(VdpDecoder decoder, struct pipe_screen *screen; struct pipe_video_decoder *dec; bool buffer_support[2]; - unsigned i, j; + unsigned i; union { struct pipe_picture_desc base; struct pipe_mpeg12_picture_desc mpeg12; @@ -557,43 +557,6 @@ vlVdpDecoderRender(VdpDecoder decoder, return ret; } - // Cleanup start_code (mandatory for some codec) from bitstream buffers - if (u_reduce_video_profile(dec->profile) == PIPE_VIDEO_CODEC_MPEG4_AVC || - u_reduce_video_profile(dec->profile) == PIPE_VIDEO_CODEC_VP8) { - int start_code_found = 0; - - for (i = 0, j = 0; i < bitstream_buffer_count; ++i) { - if (!start_code_found) { - const uint8_t *datab = (const uint8_t *)bitstream_buffers[i].bitstream; - - if ((datab[0] == 0x9D && datab[1] == 0x01 && datab[2] == 0x2A) || - (datab[0] == 0x00 && datab[1] == 0x00 && datab[2] == 0x01)) { - start_code_found = 1; - - if (bitstream_buffers[i].bitstream_bytes != 3) { - buffers[j] = bitstream_buffers[i].bitstream + 3; - sizes[j] = bitstream_buffers[i].bitstream_bytes - 3; - j++; - } - } else { - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Error : the first data buffer does not contain the mandatory start_code [0x9D012A]\n"); - return VDP_STATUS_ERROR; - } - } else { - buffers[j] = bitstream_buffers[i].bitstream; - sizes[j] = bitstream_buffers[i].bitstream_bytes; - j++; - } - } - - bitstream_buffer_count = j; - } else { - for (i = 0; i < bitstream_buffer_count; ++i) { - buffers[i] = bitstream_buffers[i].bitstream; - sizes[i] = bitstream_buffers[i].bitstream_bytes; - } - } - 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); -- cgit v1.2.3