From: Dmitry Kovalev Date: Wed, 21 May 2014 22:51:40 +0000 (-0700) Subject: Removing decoded_key_frame flag. X-Git-Tag: v1.4.0~1519^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7135a93440c2d8ef79f87b9df542c43277b6f43;p=libvpx Removing decoded_key_frame flag. Change-Id: I79576920efb7f3f6f197d386727409759d8bda8d --- diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index d6482761b..121b1f2cd 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -1317,16 +1317,15 @@ static struct vp9_read_bit_buffer* init_read_bit_buffer( return rb; } -int vp9_decode_frame(VP9Decoder *pbi, - const uint8_t *data, const uint8_t *data_end, - const uint8_t **p_data_end) { +void vp9_decode_frame(VP9Decoder *pbi, + const uint8_t *data, const uint8_t *data_end, + const uint8_t **p_data_end) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; struct vp9_read_bit_buffer rb = { 0 }; uint8_t clear_data[MAX_VP9_HEADER_SIZE]; const size_t first_partition_size = read_uncompressed_header(pbi, init_read_bit_buffer(pbi, &rb, data, data_end, clear_data)); - const int keyframe = cm->frame_type == KEY_FRAME; const int tile_rows = 1 << cm->log2_tile_rows; const int tile_cols = 1 << cm->log2_tile_cols; YV12_BUFFER_CONFIG *const new_fb = get_frame_new_buffer(cm); @@ -1335,12 +1334,9 @@ int vp9_decode_frame(VP9Decoder *pbi, if (!first_partition_size) { // showing a frame directly *p_data_end = data + 1; - return 0; + return; } - if (!pbi->decoded_key_frame && !keyframe) - return -1; - data += vp9_rb_bytes_read(&rb); if (!read_is_valid(data, first_partition_size, data_end)) vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, @@ -1377,14 +1373,6 @@ int vp9_decode_frame(VP9Decoder *pbi, new_fb->corrupted |= xd->corrupted; - if (!pbi->decoded_key_frame) { - if (keyframe && !new_fb->corrupted) - pbi->decoded_key_frame = 1; - else - vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, - "A stream must start with a complete key frame"); - } - if (!new_fb->corrupted) { if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) { vp9_adapt_coef_probs(cm); @@ -1400,6 +1388,4 @@ int vp9_decode_frame(VP9Decoder *pbi, if (cm->refresh_frame_context) cm->frame_contexts[cm->frame_context_idx] = cm->fc; - - return 0; } diff --git a/vp9/decoder/vp9_decodeframe.h b/vp9/decoder/vp9_decodeframe.h index 8a19dafc5..fb15645a9 100644 --- a/vp9/decoder/vp9_decodeframe.h +++ b/vp9/decoder/vp9_decodeframe.h @@ -21,9 +21,9 @@ struct VP9Decoder; void vp9_init_dequantizer(struct VP9Common *cm); -int vp9_decode_frame(struct VP9Decoder *pbi, - const uint8_t *data, const uint8_t *data_end, - const uint8_t **p_data_end); +void vp9_decode_frame(struct VP9Decoder *pbi, + const uint8_t *data, const uint8_t *data_end, + const uint8_t **p_data_end); #ifdef __cplusplus } // extern "C" diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c index 8902f179d..13d79ff44 100644 --- a/vp9/decoder/vp9_decoder.c +++ b/vp9/decoder/vp9_decoder.c @@ -67,7 +67,6 @@ VP9Decoder *vp9_decoder_create() { cm->current_video_frame = 0; pbi->ready_for_new_data = 1; - pbi->decoded_key_frame = 0; // vp9_init_dequantizer() is first called here. Add check in // frame_init_dequantizer() to avoid unnecessary calling of @@ -267,15 +266,7 @@ int vp9_receive_compressed_data(VP9Decoder *pbi, cm->error.setjmp = 1; - retcode = vp9_decode_frame(pbi, source, source + size, psource); - - if (retcode < 0) { - cm->error.error_code = VPX_CODEC_ERROR; - cm->error.setjmp = 0; - if (cm->frame_bufs[cm->new_fb_idx].ref_count > 0) - cm->frame_bufs[cm->new_fb_idx].ref_count--; - return retcode; - } + vp9_decode_frame(pbi, source, source + size, psource); swap_frame_buffers(pbi); diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h index 1a5576e5a..a6edf0cbd 100644 --- a/vp9/decoder/vp9_decoder.h +++ b/vp9/decoder/vp9_decoder.h @@ -43,8 +43,6 @@ typedef struct VP9Decoder { int refresh_frame_flags; - int decoded_key_frame; - VP9Worker lf_worker; VP9Worker *tile_workers; int num_tile_workers; diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 328b98fee..9cf1735cb 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -260,6 +260,9 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx, ctx->decrypt_state); if (res != VPX_CODEC_OK) return res; + + if (!ctx->si.is_kf) + return VPX_CODEC_ERROR; } // Initialize the decoder instance on the first frame