From e6635a9a19639a71c9c1f71c3b4547a0a6301d29 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 1 Jun 2011 21:56:55 -0700 Subject: h264: remove CONFIG_GPL from x86 intra prediction code. The authors permitted relicensing to LGPL a long time ago (Holger, Loren and Jason). --- libavcodec/x86/h264_intrapred.asm | 6 ------ libavcodec/x86/h264_intrapred_init.c | 8 -------- 2 files changed, 14 deletions(-) diff --git a/libavcodec/x86/h264_intrapred.asm b/libavcodec/x86/h264_intrapred.asm index 0b2f8d39df..cbf3cf7a5c 100644 --- a/libavcodec/x86/h264_intrapred.asm +++ b/libavcodec/x86/h264_intrapred.asm @@ -836,7 +836,6 @@ PRED8x8_H ssse3 ;----------------------------------------------------------------------------- ; void pred8x8_top_dc_mmxext(uint8_t *src, int stride) ;----------------------------------------------------------------------------- -%ifdef CONFIG_GPL cglobal pred8x8_top_dc_mmxext, 2,5 sub r0, r1 movq mm0, [r0] @@ -927,7 +926,6 @@ cglobal pred8x8_dc_mmxext, 2,5 movq [r4+r1*1], m1 movq [r4+r1*2], m1 RET -%endif ;----------------------------------------------------------------------------- ; void pred8x8_dc_rv40(uint8_t *src, int stride) @@ -1083,7 +1081,6 @@ cglobal pred8x8_tm_vp8_ssse3, 2,3,6 ;----------------------------------------------------------------------------- ; void pred8x8l_top_dc(uint8_t *src, int has_topleft, int has_topright, int stride) ;----------------------------------------------------------------------------- -%ifdef CONFIG_GPL %macro PRED8x8L_TOP_DC 1 cglobal pred8x8l_top_dc_%1, 4,4 sub r0, r3 @@ -2476,7 +2473,6 @@ PRED8x8L_HORIZONTAL_DOWN sse2 INIT_MMX %define PALIGNR PALIGNR_SSSE3 PRED8x8L_HORIZONTAL_DOWN ssse3 -%endif ;----------------------------------------------------------------------------- ; void pred4x4_dc_mmxext(uint8_t *src, const uint8_t *topright, int stride) @@ -2608,7 +2604,6 @@ cglobal pred4x4_vertical_vp8_mmxext, 3,3 ;----------------------------------------------------------------------------- ; void pred4x4_down_left_mmxext(uint8_t *src, const uint8_t *topright, int stride) ;----------------------------------------------------------------------------- -%ifdef CONFIG_GPL INIT_MMX cglobal pred4x4_down_left_mmxext, 3,3 sub r0, r2 @@ -2786,4 +2781,3 @@ cglobal pred4x4_down_right_mmxext, 3,3 psrlq m0, 8 movh [r0+r2*1], m0 RET -%endif diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index 9eb752581b..bd57030660 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -129,7 +129,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; -#if CONFIG_GPL h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; @@ -142,9 +141,7 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext; h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; -#endif h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; -#if CONFIG_GPL if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext; if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) @@ -156,7 +153,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; } -#endif if (codec_id == CODEC_ID_VP8) { h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext; h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; @@ -181,13 +177,11 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth if (mm_flags & AV_CPU_FLAG_SSE2) { h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; -#if CONFIG_GPL h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2; h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; -#endif if (codec_id == CODEC_ID_VP8) { h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2; h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2; @@ -207,7 +201,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; -#if CONFIG_GPL h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; @@ -218,7 +211,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; -#endif if (codec_id == CODEC_ID_VP8) { h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3; h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; -- cgit v1.2.3 From cc9947ffbe8a847a49d092c9253910cfc53279ad Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Tue, 31 May 2011 23:38:09 -0600 Subject: aacenc: Add stereo_mode option. ms_off is the default, until Mid/Side is no longer buggy. Signed-off-by: Ronald S. Bultje --- libavcodec/aacenc.c | 32 +++++++++++++++++++++++++++++--- libavcodec/aacenc.h | 6 ++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 92ff4b0e62..e8942a13f9 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -30,6 +30,7 @@ * add temporal noise shaping ***********************************/ +#include "libavutil/opt.h" #include "avcodec.h" #include "put_bits.h" #include "dsputil.h" @@ -489,7 +490,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AACEncContext *s = avctx->priv_data; int16_t *samples = s->samples, *samples2, *la; ChannelElement *cpe; - int i, ch, w, chans, tag, start_ch; + int i, ch, w, g, chans, tag, start_ch; const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; int chan_el_counter[4]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; @@ -587,8 +588,16 @@ static int aac_encode_frame(AVCodecContext *avctx, } } s->cur_channel = start_ch; - if (cpe->common_window && s->coder->search_for_ms) - s->coder->search_for_ms(s, cpe, s->lambda); + if (s->options.stereo_mode && cpe->common_window) { + if (s->options.stereo_mode > 0) { + IndividualChannelStream *ics = &cpe->ch[0].ics; + for (w = 0; w < ics->num_windows; w += ics->group_len[w]) + for (g = 0; g < ics->num_swb; g++) + cpe->ms_mask[w*16+g] = 1; + } else if (s->coder->search_for_ms) { + s->coder->search_for_ms(s, cpe, s->lambda); + } + } adjust_frame_information(s, cpe, chans); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); @@ -645,6 +654,22 @@ static av_cold int aac_encode_end(AVCodecContext *avctx) return 0; } +#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM +static const AVOption aacenc_options[] = { + {"stereo_mode", "Stereo coding method", offsetof(AACEncContext, options.stereo_mode), FF_OPT_TYPE_INT, {.dbl = 0}, -1, 1, AACENC_FLAGS, "stereo_mode"}, + {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {"ms_off", "Disable Mid/Side coding", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {"ms_force", "Force Mid/Side for the whole frame if possible", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {NULL} +}; + +static const AVClass aacenc_class = { + "AAC encoder", + av_default_item_name, + aacenc_options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_aac_encoder = { "aac", AVMEDIA_TYPE_AUDIO, @@ -656,4 +681,5 @@ AVCodec ff_aac_encoder = { .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), + .priv_class = &aacenc_class, }; diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h index 7e08db24c0..067a9b04f3 100644 --- a/libavcodec/aacenc.h +++ b/libavcodec/aacenc.h @@ -30,6 +30,10 @@ #include "psymodel.h" +typedef struct AACEncOptions { + int stereo_mode; +} AACEncOptions; + struct AACEncContext; typedef struct AACCoefficientsEncoder { @@ -48,6 +52,8 @@ extern AACCoefficientsEncoder ff_aac_coders[]; * AAC encoder context */ typedef struct AACEncContext { + AVClass *av_class; + AACEncOptions options; ///< encoding options PutBitContext pb; FFTContext mdct1024; ///< long (1024 samples) frame transform context FFTContext mdct128; ///< short (128 samples) frame transform context -- cgit v1.2.3 From 994c3550ffe032385833c21876fb121f59516079 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Wed, 1 Jun 2011 21:53:15 -0400 Subject: 2x faster h264_idct_add8_10. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/h264_idct_10bit.asm | 55 +++++++++++++++----------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm index 3d0004e09e..64089001e5 100644 --- a/libavcodec/x86/h264_idct_10bit.asm +++ b/libavcodec/x86/h264_idct_10bit.asm @@ -249,16 +249,17 @@ IDCT8_DC_ADD avx jmp .skipadd%2 %endmacro +%assign last_block 16 %macro ADD16_OP_INTRA 3 cmp word [r4+%3], 0 jnz .ac%2 - mov r6d, dword [r2+ 0] - or r6d, dword [r2+64] + mov r5d, dword [r2+ 0] + or r5d, dword [r2+64] jz .skipblock%2 - mov r5d, dword [r1+(%2+0)*4] + mov r5d, dword [r1+(%2+0)*4] call idct_dc_add_%1 .skipblock%2: -%if %2<15 +%if %2 Date: Wed, 1 Jun 2011 01:01:01 -0400 Subject: Cosmetic changes to h264_idct_10bit.asm. Removes redundant dword tags and whitespace changes. Signed-off-by: Ronald S. Bultje --- libavcodec/x86/h264_idct_10bit.asm | 139 +++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm index 64089001e5..3f7cf4cefc 100644 --- a/libavcodec/x86/h264_idct_10bit.asm +++ b/libavcodec/x86/h264_idct_10bit.asm @@ -133,7 +133,7 @@ ADD4x4IDCT avx %macro ADD16_OP 3 cmp byte [r4+%3], 0 jz .skipblock%2 - mov r5d, dword [r1+%2*4] + mov r5d, [r1+%2*4] call add4x4_idct_%1 .skipblock%2: %if %2<15 @@ -159,7 +159,7 @@ cglobal h264_idct_add16_10_%1, 5,6 ADD16_OP %1, 13, 7+3*8 ADD16_OP %1, 14, 6+4*8 ADD16_OP %1, 15, 7+4*8 - RET + REP_RET %endmacro INIT_XMM @@ -201,7 +201,7 @@ IDCT_ADD16_10 avx INIT_MMX cglobal h264_idct_dc_add_10_mmx2,3,3 - movd m0, dword [r1] + movd m0, [r1] paddd m0, [pd_32] psrad m0, 6 lea r1, [r2*3] @@ -215,7 +215,7 @@ cglobal h264_idct_dc_add_10_mmx2,3,3 ;----------------------------------------------------------------------------- %macro IDCT8_DC_ADD 1 cglobal h264_idct8_dc_add_10_%1,3,3,7 - mov r1d, dword [r1] + mov r1d, [r1] add r1, 32 sar r1, 6 movd m0, r1d @@ -240,9 +240,9 @@ IDCT8_DC_ADD avx ;----------------------------------------------------------------------------- %macro AC 2 .ac%2 - mov r5d, dword [r1+(%2+0)*4] + mov r5d, [r1+(%2+0)*4] call add4x4_idct_%1 - mov r5d, dword [r1+(%2+1)*4] + mov r5d, [r1+(%2+1)*4] add r2, 64 call add4x4_idct_%1 add r2, 64 @@ -251,16 +251,16 @@ IDCT8_DC_ADD avx %assign last_block 16 %macro ADD16_OP_INTRA 3 - cmp word [r4+%3], 0 + cmp word [r4+%3], 0 jnz .ac%2 - mov r5d, dword [r2+ 0] - or r5d, dword [r2+64] + mov r5d, [r2+ 0] + or r5d, [r2+64] jz .skipblock%2 - mov r5d, dword [r1+(%2+0)*4] + mov r5d, [r1+(%2+0)*4] call idct_dc_add_%1 .skipblock%2: %if %2 01234567 + SWAP 0, 1 + psrad m4, m5, 1 + psrad m1, m0, 1 + paddd m4, m5 + paddd m1, m0 + paddd m4, m7 + paddd m1, m5 + psubd m4, m0 + paddd m1, m3 + + psubd m0, m3 + psubd m5, m3 + paddd m0, m7 + psubd m5, m7 + psrad m3, 1 + psrad m7, 1 + psubd m0, m3 + psubd m5, m7 + + SWAP 1, 7 + psrad m1, m7, 2 + psrad m3, m4, 2 + paddd m3, m0 + psrad m0, 2 + paddd m1, m5 + psrad m5, 2 + psubd m0, m4 + psubd m7, m5 + + SWAP 5, 6 + psrad m4, m2, 1 + psrad m6, m5, 1 + psubd m4, m5 + paddd m6, m2 + + mova m2, %1 + mova m5, %2 + SUMSUB_BA d, 5, 2 + SUMSUB_BA d, 6, 5 + SUMSUB_BA d, 4, 2 + SUMSUB_BA d, 7, 6 + SUMSUB_BA d, 0, 4 + SUMSUB_BA d, 3, 2 + SUMSUB_BA d, 1, 5 + SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567 %endmacro %macro IDCT8_1D_FULL 1 @@ -523,7 +526,7 @@ IDCT8_ADD avx %macro IDCT8_ADD4_OP 3 cmp byte [r4+%3], 0 jz .skipblock%2 - mov r0d, dword [r6+%2*4] + mov r0d, [r6+%2*4] add r0, r5 call h264_idct8_add1_10_%1 .skipblock%2: -- cgit v1.2.3 From 6a9c85944427e3c4355bce67d7f677ec69527bff Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Thu, 2 Jun 2011 10:15:58 -0700 Subject: H264/MPEG frame-level multi-threading. Signed-off-by: Ronald S. Bultje --- libavcodec/error_resilience.c | 45 ++- libavcodec/h263dec.c | 8 + libavcodec/h264.c | 736 ++++++++++++++++++++++++++++++++---------- libavcodec/h264.h | 2 + libavcodec/h264_direct.c | 41 ++- libavcodec/mpeg12.c | 36 ++- libavcodec/mpeg4videodec.c | 20 +- libavcodec/mpegvideo.c | 259 ++++++++++++--- libavcodec/mpegvideo.h | 18 +- libavcodec/mpegvideo_enc.c | 24 +- libavcodec/pthread.c | 2 +- libavcodec/utils.c | 4 +- tests/fate/h264.mak | 204 ++++++------ tests/ref/vsynth1/error | 6 +- tests/ref/vsynth2/error | 6 +- tests/regression-funcs.sh | 2 +- 16 files changed, 1058 insertions(+), 355 deletions(-) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index e7588a9867..aea0e15b34 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -32,6 +32,7 @@ #include "mpegvideo.h" #include "h264.h" #include "rectangle.h" +#include "thread.h" /* * H264 redefines mb_intra so it is not mistakely used (its uninitialized in h264) @@ -428,8 +429,7 @@ int score_sum=0; int best_score=256*256*256*64; int best_pred=0; const int mot_index= (mb_x + mb_y*mot_stride) * mot_step; - int prev_x= s->current_picture.motion_val[0][mot_index][0]; - int prev_y= s->current_picture.motion_val[0][mot_index][1]; + int prev_x, prev_y, prev_ref; if((mb_x^mb_y^pass)&1) continue; @@ -527,11 +527,26 @@ skip_mean_and_median: /* zero MV */ pred_count++; + if (!fixed[mb_xy]) { + if (s->avctx->codec_id == CODEC_ID_H264) { + // FIXME + } else { + ff_thread_await_progress((AVFrame *) s->last_picture_ptr, + mb_y, 0); + } + prev_x = s->last_picture.motion_val[0][mot_index][0]; + prev_y = s->last_picture.motion_val[0][mot_index][1]; + prev_ref = s->last_picture.ref_index[0][4*mb_xy]; + } else { + prev_x = s->current_picture.motion_val[0][mot_index][0]; + prev_y = s->current_picture.motion_val[0][mot_index][1]; + prev_ref = s->current_picture.ref_index[0][4*mb_xy]; + } + /* last MV */ - mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0]; - mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1]; - ref [pred_count] = s->current_picture.ref_index[0][4*mb_xy]; - pred_count++; + mv_predictor[pred_count][0]= prev_x; + mv_predictor[pred_count][1]= prev_y; + ref [pred_count] = prev_ref; s->mv_dir = MV_DIR_FORWARD; s->mb_intra=0; @@ -662,6 +677,12 @@ static int is_intra_more_likely(MpegEncContext *s){ uint8_t *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize; uint8_t *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize; + if (s->avctx->codec_id == CODEC_ID_H264) { + // FIXME + } else { + ff_thread_await_progress((AVFrame *) s->last_picture_ptr, + mb_y, 0); + } is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16); is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16); }else{ @@ -681,6 +702,7 @@ void ff_er_frame_start(MpegEncContext *s){ memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_stride*s->mb_height*sizeof(uint8_t)); s->error_count= 3*s->mb_num; + s->error_occurred = 0; } /** @@ -720,7 +742,10 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en s->error_count -= end_i - start_i + 1; } - if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) s->error_count= INT_MAX; + if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) { + s->error_occurred = 1; + s->error_count= INT_MAX; + } if(mask == ~0x7F){ memset(&s->error_status_table[start_xy], 0, (end_xy - start_xy) * sizeof(uint8_t)); @@ -995,6 +1020,12 @@ void ff_er_frame_end(MpegEncContext *s){ int time_pp= s->pp_time; int time_pb= s->pb_time; + if (s->avctx->codec_id == CODEC_ID_H264) { + //FIXME + } else { + ff_thread_await_progress((AVFrame *) s->next_picture_ptr, + mb_y, 0); + } s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp; s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp; s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp; diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index e2627fa8e4..bc6d613be4 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -35,6 +35,7 @@ #include "mpeg4video_parser.h" #include "msmpeg4.h" #include "vdpau_internal.h" +#include "thread.h" #include "flv.h" #include "mpeg4video.h" @@ -229,6 +230,7 @@ static int decode_slice(MpegEncContext *s){ if(++s->mb_x >= s->mb_width){ s->mb_x=0; ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size); + MPV_report_decode_progress(s); s->mb_y++; } return 0; @@ -249,6 +251,7 @@ static int decode_slice(MpegEncContext *s){ } ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size); + MPV_report_decode_progress(s); s->mb_x= 0; } @@ -609,6 +612,8 @@ retry: if(MPV_frame_start(s, avctx) < 0) return -1; + if (!s->divx_packed) ff_thread_finish_setup(avctx); + if (CONFIG_MPEG4_VDPAU_DECODER && (s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)) { ff_vdpau_mpeg4_decode_picture(s, s->gb.buffer, s->gb.buffer_end - s->gb.buffer); goto frame_end; @@ -639,8 +644,11 @@ retry: if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits) break; }else{ + int prev_x=s->mb_x, prev_y=s->mb_y; if(ff_h263_resync(s)<0) break; + if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x) + s->error_occurred = 1; } if(s->msmpeg4_version<4 && s->h263_pred) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index eb873a4855..0aa923fdbb 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -36,6 +36,7 @@ #include "golomb.h" #include "mathops.h" #include "rectangle.h" +#include "thread.h" #include "vdpau_internal.h" #include "libavutil/avassert.h" @@ -245,6 +246,141 @@ static int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){ return 0; } +static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n, int height, + int y_offset, int list){ + int raw_my= h->mv_cache[list][ scan8[n] ][1]; + int filter_height= (raw_my&3) ? 2 : 0; + int full_my= (raw_my>>2) + y_offset; + int top = full_my - filter_height, bottom = full_my + height + filter_height; + + return FFMAX(abs(top), bottom); +} + +static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int height, + int y_offset, int list0, int list1, int *nrefs){ + MpegEncContext * const s = &h->s; + int my; + + y_offset += 16*(s->mb_y >> MB_FIELD); + + if(list0){ + int ref_n = h->ref_cache[0][ scan8[n] ]; + Picture *ref= &h->ref_list[0][ref_n]; + + // Error resilience puts the current picture in the ref list. + // Don't try to wait on these as it will cause a deadlock. + // Fields can wait on each other, though. + if(ref->thread_opaque != s->current_picture.thread_opaque || + (ref->reference&3) != s->picture_structure) { + my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0); + if (refs[0][ref_n] < 0) nrefs[0] += 1; + refs[0][ref_n] = FFMAX(refs[0][ref_n], my); + } + } + + if(list1){ + int ref_n = h->ref_cache[1][ scan8[n] ]; + Picture *ref= &h->ref_list[1][ref_n]; + + if(ref->thread_opaque != s->current_picture.thread_opaque || + (ref->reference&3) != s->picture_structure) { + my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1); + if (refs[1][ref_n] < 0) nrefs[1] += 1; + refs[1][ref_n] = FFMAX(refs[1][ref_n], my); + } + } +} + +/** + * Wait until all reference frames are available for MC operations. + * + * @param h the H264 context + */ +static void await_references(H264Context *h){ + MpegEncContext * const s = &h->s; + const int mb_xy= h->mb_xy; + const int mb_type= s->current_picture.mb_type[mb_xy]; + int refs[2][48]; + int nrefs[2] = {0}; + int ref, list; + + memset(refs, -1, sizeof(refs)); + + if(IS_16X16(mb_type)){ + get_lowest_part_y(h, refs, 0, 16, 0, + IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs); + }else if(IS_16X8(mb_type)){ + get_lowest_part_y(h, refs, 0, 8, 0, + IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs); + get_lowest_part_y(h, refs, 8, 8, 8, + IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs); + }else if(IS_8X16(mb_type)){ + get_lowest_part_y(h, refs, 0, 16, 0, + IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs); + get_lowest_part_y(h, refs, 4, 16, 0, + IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs); + }else{ + int i; + + assert(IS_8X8(mb_type)); + + for(i=0; i<4; i++){ + const int sub_mb_type= h->sub_mb_type[i]; + const int n= 4*i; + int y_offset= (i&2)<<2; + + if(IS_SUB_8X8(sub_mb_type)){ + get_lowest_part_y(h, refs, n , 8, y_offset, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + }else if(IS_SUB_8X4(sub_mb_type)){ + get_lowest_part_y(h, refs, n , 4, y_offset, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + get_lowest_part_y(h, refs, n+2, 4, y_offset+4, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + }else if(IS_SUB_4X8(sub_mb_type)){ + get_lowest_part_y(h, refs, n , 8, y_offset, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + get_lowest_part_y(h, refs, n+1, 8, y_offset, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + }else{ + int j; + assert(IS_SUB_4X4(sub_mb_type)); + for(j=0; j<4; j++){ + int sub_y_offset= y_offset + 2*(j&2); + get_lowest_part_y(h, refs, n+j, 4, sub_y_offset, + IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs); + } + } + } + } + + for(list=h->list_count-1; list>=0; list--){ + for(ref=0; ref<48 && nrefs[list]; ref++){ + int row = refs[list][ref]; + if(row >= 0){ + Picture *ref_pic = &h->ref_list[list][ref]; + int ref_field = ref_pic->reference - 1; + int ref_field_picture = ref_pic->field_picture; + int pic_height = 16*s->mb_height >> ref_field_picture; + + row <<= MB_MBAFF; + nrefs[list]--; + + if(!FIELD_PICTURE && ref_field_picture){ // frame referencing two fields + ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) - !(row&1), pic_height-1), 1); + ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) , pic_height-1), 0); + }else if(FIELD_PICTURE && !ref_field_picture){ // field referencing one field of a frame + ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row*2 + ref_field , pic_height-1), 0); + }else if(FIELD_PICTURE){ + ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), ref_field); + }else{ + ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), 0); + } + } + } + } +} + #if 0 /** * DCT transforms the 16 dc values. @@ -518,6 +654,8 @@ static av_always_inline void hl_motion(H264Context *h, uint8_t *dest_y, uint8_t assert(IS_INTER(mb_type)); + if(HAVE_PTHREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) + await_references(h); prefetch_motion(h, 0, pixel_shift); if(IS_16X16(mb_type)){ @@ -626,6 +764,7 @@ hl_motion_fn(1, 16); static void free_tables(H264Context *h, int free_rbsp){ int i; H264Context *hx; + av_freep(&h->intra4x4_pred_mode); av_freep(&h->chroma_pred_mode_table); av_freep(&h->cbp_table); @@ -898,7 +1037,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8; h->thread_context[0] = h; - h->outputed_poc = INT_MIN; + h->outputed_poc = h->next_outputed_poc = INT_MIN; h->prev_poc_msb= 1<<16; h->x264_build = -1; ff_h264_reset_sei(h); @@ -921,10 +1060,135 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){ return 0; } +#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b)+(size)))) +static void copy_picture_range(Picture **to, Picture **from, int count, MpegEncContext *new_base, MpegEncContext *old_base) +{ + int i; + + for (i=0; ipicture, sizeof(Picture) * old_base->picture_count) || + !from[i])); + to[i] = REBASE_PICTURE(from[i], new_base, old_base); + } +} + +static void copy_parameter_set(void **to, void **from, int count, int size) +{ + int i; + + for (i=0; ipriv_data; + + if (!avctx->is_copy) return 0; + memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); + memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); + + return 0; +} + +#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field) +static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src){ + H264Context *h= dst->priv_data, *h1= src->priv_data; + MpegEncContext * const s = &h->s, * const s1 = &h1->s; + int inited = s->context_initialized, err; + int i; + + if(dst == src || !s1->context_initialized) return 0; + + err = ff_mpeg_update_thread_context(dst, src); + if(err) return err; + + //FIXME handle width/height changing + if(!inited){ + for(i = 0; i < MAX_SPS_COUNT; i++) + av_freep(h->sps_buffers + i); + + for(i = 0; i < MAX_PPS_COUNT; i++) + av_freep(h->pps_buffers + i); + + memcpy(&h->s + 1, &h1->s + 1, sizeof(H264Context) - sizeof(MpegEncContext)); //copy all fields after MpegEnc + memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); + memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); + ff_h264_alloc_tables(h); + context_init(h); + + for(i=0; i<2; i++){ + h->rbsp_buffer[i] = NULL; + h->rbsp_buffer_size[i] = 0; + } + + h->thread_context[0] = h; + + // frame_start may not be called for the next thread (if it's decoding a bottom field) + // so this has to be allocated here + h->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize); + + s->dsp.clear_blocks(h->mb); + } + + //extradata/NAL handling + h->is_avc = h1->is_avc; + + //SPS/PPS + copy_parameter_set((void**)h->sps_buffers, (void**)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS)); + h->sps = h1->sps; + copy_parameter_set((void**)h->pps_buffers, (void**)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS)); + h->pps = h1->pps; + + //Dequantization matrices + //FIXME these are big - can they be only copied when PPS changes? + copy_fields(h, h1, dequant4_buffer, dequant4_coeff); + + for(i=0; i<6; i++) + h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]); + + for(i=0; i<2; i++) + h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]); + + h->dequant_coeff_pps = h1->dequant_coeff_pps; + + //POC timing + copy_fields(h, h1, poc_lsb, redundant_pic_count); + + //reference lists + copy_fields(h, h1, ref_count, list_count); + copy_fields(h, h1, ref_list, intra_gb); + copy_fields(h, h1, short_ref, cabac_init_idc); + + copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1); + copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1); + copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT+2, s, s1); + + h->last_slice_type = h1->last_slice_type; + + if(!s->current_picture_ptr) return 0; + + if(!s->dropable) { + ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); + h->prev_poc_msb = h->poc_msb; + h->prev_poc_lsb = h->poc_lsb; + } + h->prev_frame_num_offset= h->frame_num_offset; + h->prev_frame_num = h->frame_num; + h->outputed_poc = h->next_outputed_poc; + + return 0; +} + int ff_h264_frame_start(H264Context *h){ MpegEncContext * const s = &h->s; int i; const int pixel_shift = h->pixel_shift; + int thread_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; if(MPV_frame_start(s, s->avctx) < 0) return -1; @@ -953,7 +1217,7 @@ int ff_h264_frame_start(H264Context *h){ /* can't be in alloc_tables because linesize isn't known there. * FIXME: redo bipred weight to not require extra buffer? */ - for(i = 0; i < s->avctx->thread_count; i++) + for(i = 0; i < thread_count; i++) if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad) h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize); @@ -973,11 +1237,173 @@ int ff_h264_frame_start(H264Context *h){ s->current_picture_ptr->field_poc[0]= s->current_picture_ptr->field_poc[1]= INT_MAX; + + h->next_output_pic = NULL; + assert(s->current_picture_ptr->long_ref==0); return 0; } +/** + * Run setup operations that must be run after slice header decoding. + * This includes finding the next displayed frame. + * + * @param h h264 master context + * @param setup_finished enough NALs have been read that we can call + * ff_thread_finish_setup() + */ +static void decode_postinit(H264Context *h, int setup_finished){ + MpegEncContext * const s = &h->s; + Picture *out = s->current_picture_ptr; + Picture *cur = s->current_picture_ptr; + int i, pics, out_of_order, out_idx; + + s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264; + s->current_picture_ptr->pict_type= s->pict_type; + + if (h->next_output_pic) return; + + if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { + //FIXME: if we have two PAFF fields in one packet, we can't start the next thread here. + //If we have one field per packet, we can. The check in decode_nal_units() is not good enough + //to find this yet, so we assume the worst for now. + //if (setup_finished) + // ff_thread_finish_setup(s->avctx); + return; + } + + cur->interlaced_frame = 0; + cur->repeat_pict = 0; + + /* Signal interlacing information externally. */ + /* Prioritize picture timing SEI information over used decoding process if it exists. */ + + if(h->sps.pic_struct_present_flag){ + switch (h->sei_pic_struct) + { + case SEI_PIC_STRUCT_FRAME: + break; + case SEI_PIC_STRUCT_TOP_FIELD: + case SEI_PIC_STRUCT_BOTTOM_FIELD: + cur->interlaced_frame = 1; + break; + case SEI_PIC_STRUCT_TOP_BOTTOM: + case SEI_PIC_STRUCT_BOTTOM_TOP: + if (FIELD_OR_MBAFF_PICTURE) + cur->interlaced_frame = 1; + else + // try to flag soft telecine progressive + cur->interlaced_frame = h->prev_interlaced_frame; + break; + case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: + case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: + // Signal the possibility of telecined film externally (pic_struct 5,6) + // From these hints, let the applications decide if they apply deinterlacing. + cur->repeat_pict = 1; + break; + case SEI_PIC_STRUCT_FRAME_DOUBLING: + // Force progressive here, as doubling interlaced frame is a bad idea. + cur->repeat_pict = 2; + break; + case SEI_PIC_STRUCT_FRAME_TRIPLING: + cur->repeat_pict = 4; + break; + } + + if ((h->sei_ct_type & 3) && h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) + cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0; + }else{ + /* Derive interlacing flag from used decoding process. */ + cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE; + } + h->prev_interlaced_frame = cur->interlaced_frame; + + if (cur->field_poc[0] != cur->field_poc[1]){ + /* Derive top_field_first from field pocs. */ + cur->top_field_first = cur->field_poc[0] < cur->field_poc[1]; + }else{ + if(cur->interlaced_frame || h->sps.pic_struct_present_flag){ + /* Use picture timing SEI information. Even if it is a information of a past frame, better than nothing. */ + if(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM + || h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) + cur->top_field_first = 1; + else + cur->top_field_first = 0; + }else{ + /* Most likely progressive */ + cur->top_field_first = 0; + } + } + + //FIXME do something with unavailable reference frames + + /* Sort B-frames into display order */ + + if(h->sps.bitstream_restriction_flag + && s->avctx->has_b_frames < h->sps.num_reorder_frames){ + s->avctx->has_b_frames = h->sps.num_reorder_frames; + s->low_delay = 0; + } + + if( s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT + && !h->sps.bitstream_restriction_flag){ + s->avctx->has_b_frames= MAX_DELAYED_PIC_COUNT; + s->low_delay= 0; + } + + pics = 0; + while(h->delayed_pic[pics]) pics++; + + assert(pics <= MAX_DELAYED_PIC_COUNT); + + h->delayed_pic[pics++] = cur; + if(cur->reference == 0) + cur->reference = DELAYED_PIC_REF; + + out = h->delayed_pic[0]; + out_idx = 0; + for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) + if(h->delayed_pic[i]->poc < out->poc){ + out = h->delayed_pic[i]; + out_idx = i; + } + if(s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) + h->next_outputed_poc= INT_MIN; + out_of_order = out->poc < h->next_outputed_poc; + + if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) + { } + else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) + || (s->low_delay && + ((h->next_outputed_poc != INT_MIN && out->poc > h->next_outputed_poc + 2) + || cur->pict_type == AV_PICTURE_TYPE_B))) + { + s->low_delay = 0; + s->avctx->has_b_frames++; + } + + if(out_of_order || pics > s->avctx->has_b_frames){ + out->reference &= ~DELAYED_PIC_REF; + out->owner2 = s; // for frame threading, the owner must be the second field's thread + // or else the first thread can release the picture and reuse it unsafely + for(i=out_idx; h->delayed_pic[i]; i++) + h->delayed_pic[i] = h->delayed_pic[i+1]; + } + if(!out_of_order && pics > s->avctx->has_b_frames){ + h->next_output_pic = out; + if(out_idx==0 && h->delayed_pic[0] && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) { + h->next_outputed_poc = INT_MIN; + } else + h->next_outputed_poc = out->poc; + }else{ + av_log(s->avctx, AV_LOG_DEBUG, "no picture\n"); + } + + if (setup_finished) + ff_thread_finish_setup(s->avctx); +} + static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple){ MpegEncContext * const s = &h->s; uint8_t *top_border; @@ -1573,7 +1999,7 @@ static void flush_dpb(AVCodecContext *avctx){ h->delayed_pic[i]->reference= 0; h->delayed_pic[i]= NULL; } - h->outputed_poc= INT_MIN; + h->outputed_poc=h->next_outputed_poc= INT_MIN; h->prev_interlaced_frame = 1; idr(h); if(h->s.current_picture_ptr) @@ -1697,24 +2123,28 @@ static void init_scan_tables(H264Context *h){ } } -static void field_end(H264Context *h){ +static void field_end(H264Context *h, int in_setup){ MpegEncContext * const s = &h->s; AVCodecContext * const avctx= s->avctx; s->mb_y= 0; - s->current_picture_ptr->qscale_type= FF_QSCALE_TYPE_H264; - s->current_picture_ptr->pict_type= s->pict_type; + if (!in_setup && !s->dropable) + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, (16*s->mb_height >> FIELD_PICTURE) - 1, + s->picture_structure==PICT_BOTTOM_FIELD); if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_set_reference_frames(s); - if(!s->dropable) { - ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); - h->prev_poc_msb= h->poc_msb; - h->prev_poc_lsb= h->poc_lsb; + if(in_setup || !(avctx->active_thread_type&FF_THREAD_FRAME)){ + if(!s->dropable) { + ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); + h->prev_poc_msb= h->poc_msb; + h->prev_poc_lsb= h->poc_lsb; + } + h->prev_frame_num_offset= h->frame_num_offset; + h->prev_frame_num= h->frame_num; + h->outputed_poc = h->next_outputed_poc; } - h->prev_frame_num_offset= h->frame_num_offset; - h->prev_frame_num= h->frame_num; if (avctx->hwaccel) { if (avctx->hwaccel->end_frame(avctx) < 0) @@ -1831,7 +2261,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ if(first_mb_in_slice == 0){ //FIXME better field boundary detection if(h0->current_slice && FIELD_PICTURE){ - field_end(h); + field_end(h, 1); } h0->current_slice = 0; @@ -1900,8 +2330,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ if (s->context_initialized && ( s->width != s->avctx->width || s->height != s->avctx->height || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) { - if(h != h0) + if(h != h0) { + av_log_missing_feature(s->avctx, "Width/height changing with threads is", 0); return -1; // width / height changed during parallelized decoding + } free_tables(h, 0); flush_dpb(s->avctx); MPV_common_end(s); @@ -1960,22 +2392,27 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ init_scan_tables(h); ff_h264_alloc_tables(h); - for(i = 1; i < s->avctx->thread_count; i++) { - H264Context *c; - c = h->thread_context[i] = av_malloc(sizeof(H264Context)); - memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); - memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); - c->h264dsp = h->h264dsp; - c->sps = h->sps; - c->pps = h->pps; - c->pixel_shift = h->pixel_shift; - init_scan_tables(c); - clone_tables(c, h, i); - } - - for(i = 0; i < s->avctx->thread_count; i++) - if(context_init(h->thread_context[i]) < 0) + if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_SLICE)) { + if (context_init(h) < 0) return -1; + } else { + for(i = 1; i < s->avctx->thread_count; i++) { + H264Context *c; + c = h->thread_context[i] = av_malloc(sizeof(H264Context)); + memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); + memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); + c->h264dsp = h->h264dsp; + c->sps = h->sps; + c->pps = h->pps; + c->pixel_shift = h->pixel_shift; + init_scan_tables(c); + clone_tables(c, h, i); + } + + for(i = 0; i < s->avctx->thread_count; i++) + if(context_init(h->thread_context[i]) < 0) + return -1; + } } h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num); @@ -1996,6 +2433,10 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME; if(h0->current_slice == 0){ + if(h->frame_num != h->prev_frame_num && + (h->prev_frame_num+1)%(1<sps.log2_max_frame_num) < (h->frame_num - h->sps.ref_frame_count)) + h->prev_frame_num = h->frame_num - h->sps.ref_frame_count - 1; + while(h->frame_num != h->prev_frame_num && h->frame_num != (h->prev_frame_num+1)%(1<sps.log2_max_frame_num)){ Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL; @@ -2005,6 +2446,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ h->prev_frame_num++; h->prev_frame_num %= 1<sps.log2_max_frame_num; s->current_picture_ptr->frame_num= h->prev_frame_num; + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 0); + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 1); ff_generate_sliding_window_mmcos(h); ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); /* Error concealment: if a ref is missing, copy the previous ref in its place. @@ -2064,9 +2507,13 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ s0->first_field = FIELD_PICTURE; } - if((!FIELD_PICTURE || s0->first_field) && ff_h264_frame_start(h) < 0) { - s0->first_field = 0; - return -1; + if(!FIELD_PICTURE || s0->first_field) { + if (ff_h264_frame_start(h) < 0) { + s0->first_field = 0; + return -1; + } + } else { + ff_release_unused_pictures(s, 0); } } if(h != h0) @@ -2309,7 +2756,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ +(h->ref_list[j][i].reference&3); } - h->emu_edge_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; + //FIXME: fix draw_edges+PAFF+frame threads + h->emu_edge_width= (s->flags&CODEC_FLAG_EMU_EDGE || (!h->sps.frame_mbs_only_flag && s->avctx->active_thread_type)) ? 0 : 16; h->emu_edge_height= (FRAME_MBAFF || FIELD_PICTURE) ? 0 : h->emu_edge_width; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ @@ -2631,6 +3079,40 @@ static void predict_field_decoding_flag(H264Context *h){ h->mb_mbaff = h->mb_field_decoding_flag = IS_INTERLACED(mb_type) ? 1 : 0; } +/** + * Draw edges and report progress for the last MB row. + */ +static void decode_finish_row(H264Context *h){ + MpegEncContext * const s = &h->s; + int top = 16*(s->mb_y >> FIELD_PICTURE); + int height = 16 << FRAME_MBAFF; + int deblock_border = (16 + 4) << FRAME_MBAFF; + int pic_height = 16*s->mb_height >> FIELD_PICTURE; + + if (h->deblocking_filter) { + if((top + height) >= pic_height) + height += deblock_border; + + top -= deblock_border; + } + + if (top >= pic_height || (top + height) < h->emu_edge_height) + return; + + height = FFMIN(height, pic_height - top); + if (top < h->emu_edge_height) { + height = top+height; + top = 0; + } + + ff_draw_horiz_band(s, top, height); + + if (s->dropable) return; + + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, top + height - 1, + s->picture_structure==PICT_BOTTOM_FIELD); +} + static int decode_slice(struct AVCodecContext *avctx, void *arg){ H264Context *h = *(void**)arg; MpegEncContext * const s = &h->s; @@ -2686,7 +3168,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ if( ++s->mb_x >= s->mb_width ) { loop_filter(h, lf_x_start, s->mb_x); s->mb_x = lf_x_start = 0; - ff_draw_horiz_band(s, 16*s->mb_y, 16); + decode_finish_row(h); ++s->mb_y; if(FIELD_OR_MBAFF_PICTURE) { ++s->mb_y; @@ -2726,7 +3208,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){ if(++s->mb_x >= s->mb_width){ loop_filter(h, lf_x_start, s->mb_x); s->mb_x = lf_x_start = 0; - ff_draw_horiz_band(s, 16*s->mb_y, 16); + decode_finish_row(h); ++s->mb_y; if(FIELD_OR_MBAFF_PICTURE) { ++s->mb_y; @@ -2855,12 +3337,15 @@ static void execute_decode_slices(H264Context *h, int context_count){ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ MpegEncContext * const s = &h->s; AVCodecContext * const avctx= s->avctx; - int buf_index=0; H264Context *hx; ///< thread context - int context_count = 0; - int next_avc= h->is_avc ? 0 : buf_size; + int buf_index; + int context_count; + int next_avc; + int pass = !(avctx->active_thread_type & FF_THREAD_FRAME); + int nals_needed=0; ///< number of NALs that need decoding before the next frame thread starts + int nal_index; - h->max_contexts = avctx->thread_count; + h->max_contexts = (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_SLICE)) ? avctx->thread_count : 1; if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){ h->current_slice = 0; if (!s->first_field) @@ -2868,6 +3353,11 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ ff_h264_reset_sei(h); } + for(;pass <= 1;pass++){ + buf_index = 0; + context_count = 0; + next_avc = h->is_avc ? 0 : buf_size; + nal_index = 0; for(;;){ int consumed; int dst_length; @@ -2926,6 +3416,19 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ } buf_index += consumed; + nal_index++; + + if(pass == 0) { + // packets can sometimes contain multiple PPS/SPS + // e.g. two PAFF field pictures in one packet, or a demuxer which splits NALs strangely + // if so, when frame threading we can't start the next thread until we've read all of them + switch (hx->nal_unit_type) { + case NAL_SPS: + case NAL_PPS: + nals_needed = nal_index; + } + continue; + } //FIXME do not discard SEI id if(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0) @@ -2949,16 +3452,21 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ if((err = decode_slice_header(hx, h))) break; + s->current_picture_ptr->key_frame |= + (hx->nal_unit_type == NAL_IDR_SLICE) || + (h->sei_recovery_frame_cnt >= 0); + if (h->current_slice == 1) { + if(!(s->flags2 & CODEC_FLAG2_CHUNKS)) { + decode_postinit(h, nal_index >= nals_needed); + } + if (s->avctx->hwaccel && s->avctx->hwaccel->start_frame(s->avctx, NULL, 0) < 0) return -1; if(CONFIG_H264_VDPAU_DECODER && s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) ff_vdpau_h264_picture_start(s); } - s->current_picture_ptr->key_frame |= - (hx->nal_unit_type == NAL_IDR_SLICE) || - (h->sei_recovery_frame_cnt >= 0); if(hx->redundant_pic_count==0 && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc) && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos!=AV_PICTURE_TYPE_B) @@ -3066,6 +3574,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ goto again; } } + } if(context_count) execute_decode_slices(h, context_count); return buf_index; @@ -3101,6 +3610,8 @@ static int decode_frame(AVCodecContext *avctx, Picture *out; int i, out_idx; + s->current_picture_ptr = NULL; + //FIXME factorize this with the output code below out = h->delayed_pic[0]; out_idx = 0; @@ -3138,143 +3649,18 @@ static int decode_frame(AVCodecContext *avctx, } if(!(s->flags2 & CODEC_FLAG2_CHUNKS) || (s->mb_y >= s->mb_height && s->mb_height)){ - Picture *out = s->current_picture_ptr; - Picture *cur = s->current_picture_ptr; - int i, pics, out_of_order, out_idx; - field_end(h); + if(s->flags2 & CODEC_FLAG2_CHUNKS) decode_postinit(h, 1); + + field_end(h, 0); - if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { + if (!h->next_output_pic) { /* Wait for second field. */ *data_size = 0; } else { - cur->interlaced_frame = 0; - cur->repeat_pict = 0; - - /* Signal interlacing information externally. */ - /* Prioritize picture timing SEI information over used decoding process if it exists. */ - - if(h->sps.pic_struct_present_flag){ - switch (h->sei_pic_struct) - { - case SEI_PIC_STRUCT_FRAME: - break; - case SEI_PIC_STRUCT_TOP_FIELD: - case SEI_PIC_STRUCT_BOTTOM_FIELD: - cur->interlaced_frame = 1; - break; - case SEI_PIC_STRUCT_TOP_BOTTOM: - case SEI_PIC_STRUCT_BOTTOM_TOP: - if (FIELD_OR_MBAFF_PICTURE) - cur->interlaced_frame = 1; - else - // try to flag soft telecine progressive - cur->interlaced_frame = h->prev_interlaced_frame; - break; - case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: - case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: - // Signal the possibility of telecined film externally (pic_struct 5,6) - // From these hints, let the applications decide if they apply deinterlacing. - cur->repeat_pict = 1; - break; - case SEI_PIC_STRUCT_FRAME_DOUBLING: - // Force progressive here, as doubling interlaced frame is a bad idea. - cur->repeat_pict = 2; - break; - case SEI_PIC_STRUCT_FRAME_TRIPLING: - cur->repeat_pict = 4; - break; - } - - if ((h->sei_ct_type & 3) && h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) - cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0; - }else{ - /* Derive interlacing flag from used decoding process. */ - cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE; - } - h->prev_interlaced_frame = cur->interlaced_frame; - - if (cur->field_poc[0] != cur->field_poc[1]){ - /* Derive top_field_first from field pocs. */ - cur->top_field_first = cur->field_poc[0] < cur->field_poc[1]; - }else{ - if(cur->interlaced_frame || h->sps.pic_struct_present_flag){ - /* Use picture timing SEI information. Even if it is a information of a past frame, better than nothing. */ - if(h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM - || h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) - cur->top_field_first = 1; - else - cur->top_field_first = 0; - }else{ - /* Most likely progressive */ - cur->top_field_first = 0; - } - } - - //FIXME do something with unavailable reference frames - - /* Sort B-frames into display order */ - - if(h->sps.bitstream_restriction_flag - && s->avctx->has_b_frames < h->sps.num_reorder_frames){ - s->avctx->has_b_frames = h->sps.num_reorder_frames; - s->low_delay = 0; - } - - if( s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT - && !h->sps.bitstream_restriction_flag){ - s->avctx->has_b_frames= MAX_DELAYED_PIC_COUNT; - s->low_delay= 0; - } - - pics = 0; - while(h->delayed_pic[pics]) pics++; - - assert(pics <= MAX_DELAYED_PIC_COUNT); - - h->delayed_pic[pics++] = cur; - if(cur->reference == 0) - cur->reference = DELAYED_PIC_REF; - - out = h->delayed_pic[0]; - out_idx = 0; - for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame && !h->delayed_pic[i]->mmco_reset; i++) - if(h->delayed_pic[i]->poc < out->poc){ - out = h->delayed_pic[i]; - out_idx = i; - } - if(s->avctx->has_b_frames == 0 && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) - h->outputed_poc= INT_MIN; - out_of_order = out->poc < h->outputed_poc; - - if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) - { } - else if((out_of_order && pics-1 == s->avctx->has_b_frames && s->avctx->has_b_frames < MAX_DELAYED_PIC_COUNT) - || (s->low_delay && - ((h->outputed_poc != INT_MIN && out->poc > h->outputed_poc + 2) - || cur->pict_type == AV_PICTURE_TYPE_B))) - { - s->low_delay = 0; - s->avctx->has_b_frames++; - } - - if(out_of_order || pics > s->avctx->has_b_frames){ - out->reference &= ~DELAYED_PIC_REF; - for(i=out_idx; h->delayed_pic[i]; i++) - h->delayed_pic[i] = h->delayed_pic[i+1]; - } - if(!out_of_order && pics > s->avctx->has_b_frames){ - *data_size = sizeof(AVFrame); - - if(out_idx==0 && h->delayed_pic[0] && (h->delayed_pic[0]->key_frame || h->delayed_pic[0]->mmco_reset)) { - h->outputed_poc = INT_MIN; - } else - h->outputed_poc = out->poc; - *pict= *(AVFrame*)out; - }else{ - av_log(avctx, AV_LOG_DEBUG, "no picture\n"); - } + *data_size = sizeof(AVFrame); + *pict = *(AVFrame*)h->next_output_pic; } } @@ -3534,9 +3920,11 @@ AVCodec ff_h264_decoder = { ff_h264_decode_end, decode_frame, /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY | - CODEC_CAP_SLICE_THREADS, + CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS, .flush= flush_dpb, .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), + .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), + .update_thread_context = ONLY_IF_THREADS_ENABLED(decode_update_thread_context), .profiles = NULL_IF_CONFIG_SMALL(profiles), }; diff --git a/libavcodec/h264.h b/libavcodec/h264.h index 035927a09a..5c275e2de0 100644 --- a/libavcodec/h264.h +++ b/libavcodec/h264.h @@ -506,7 +506,9 @@ typedef struct H264Context{ Picture *long_ref[32]; Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size? + Picture *next_output_pic; int outputed_poc; + int next_outputed_poc; /** * memory management control operations buffer. diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c index 3c7f57aa0c..a7e6853b5c 100644 --- a/libavcodec/h264_direct.c +++ b/libavcodec/h264_direct.c @@ -31,6 +31,7 @@ #include "mpegvideo.h" #include "h264.h" #include "rectangle.h" +#include "thread.h" //#undef NDEBUG #include @@ -126,7 +127,7 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); ref1sidx=sidx= h->col_parity; }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){ // FL -> FL & differ parity - h->col_fieldoff= s->mb_stride*(2*(h->ref_list[1][0].reference) - 3); + h->col_fieldoff= 2*(h->ref_list[1][0].reference) - 3; } if(cur->pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred) @@ -140,11 +141,27 @@ void ff_h264_direct_ref_list_init(H264Context * const h){ } } +static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y) +{ + int ref_field = ref->reference - 1; + int ref_field_picture = ref->field_picture; + int ref_height = 16*h->s.mb_height >> ref_field_picture; + + if(!HAVE_PTHREADS || !(h->s.avctx->active_thread_type&FF_THREAD_FRAME)) + return; + + //FIXME it can be safe to access mb stuff + //even if pixels aren't deblocked yet + + ff_thread_await_progress((AVFrame*)ref, FFMIN(16*mb_y >> ref_field_picture, ref_height-1), + ref_field_picture && ref_field); +} + static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ MpegEncContext * const s = &h->s; int b8_stride = 2; int b4_stride = h->b_stride; - int mb_xy = h->mb_xy; + int mb_xy = h->mb_xy, mb_y = s->mb_y; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; @@ -157,6 +174,8 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ assert(h->ref_list[1][0].reference&3); + await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); + #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) @@ -217,14 +236,17 @@ static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){ if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL + mb_y = (s->mb_y&~1) + h->col_parity; mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; }else{ - mb_xy += h->col_fieldoff; // non zero for FL -> FL & differ parity + mb_y += h->col_fieldoff; + mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity } goto single_col; }else{ // AFL/AFR/FR/FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR + mb_y = s->mb_y&~1; mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; @@ -260,6 +282,8 @@ single_col: } } + await_reference_mb_row(h, &h->ref_list[1][0], mb_y); + l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; @@ -384,7 +408,7 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ MpegEncContext * const s = &h->s; int b8_stride = 2; int b4_stride = h->b_stride; - int mb_xy = h->mb_xy; + int mb_xy = h->mb_xy, mb_y = s->mb_y; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; @@ -394,16 +418,21 @@ static void pred_temp_direct_motion(H264Context * const h, int *mb_type){ assert(h->ref_list[1][0].reference&3); + await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type)); + if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL + mb_y = (s->mb_y&~1) + h->col_parity; mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride; b8_stride = 0; }else{ - mb_xy += h->col_fieldoff; // non zero for FL -> FL & differ parity + mb_y += h->col_fieldoff; + mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity } goto single_col; }else{ // AFL/AFR/FR/FL -> AFR/FR if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR + mb_y = s->mb_y&~1; mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; mb_type_col[0] = h->ref_list[1][0].mb_type[mb_xy]; mb_type_col[1] = h->ref_list[1][0].mb_type[mb_xy + s->mb_stride]; @@ -440,6 +469,8 @@ single_col: } } + await_reference_mb_row(h, &h->ref_list[1][0], mb_y); + l1mv0 = &h->ref_list[1][0].motion_val[0][h->mb2b_xy [mb_xy]]; l1mv1 = &h->ref_list[1][0].motion_val[1][h->mb2b_xy [mb_xy]]; l1ref0 = &h->ref_list[1][0].ref_index [0][4*mb_xy]; diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 88ed5332ae..82c2987b90 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -37,6 +37,7 @@ #include "bytestream.h" #include "vdpau_internal.h" #include "xvmc_internal.h" +#include "thread.h" //#undef NDEBUG //#include @@ -1179,6 +1180,27 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) return 0; } +static int mpeg_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from) +{ + Mpeg1Context *ctx = avctx->priv_data, *ctx_from = avctx_from->priv_data; + MpegEncContext *s = &ctx->mpeg_enc_ctx, *s1 = &ctx_from->mpeg_enc_ctx; + int err; + + if(avctx == avctx_from || !ctx_from->mpeg_enc_ctx_allocated || !s1->context_initialized) + return 0; + + err = ff_mpeg_update_thread_context(avctx, avctx_from); + if(err) return err; + + if(!ctx->mpeg_enc_ctx_allocated) + memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext)); + + if(!(s->pict_type == FF_B_TYPE || s->low_delay)) + s->picture_number++; + + return 0; +} + static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm, const uint8_t *new_perm){ uint16_t temp_matrix[64]; @@ -1595,6 +1617,9 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) } *s->current_picture_ptr->pan_scan= s1->pan_scan; + + if (HAVE_PTHREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) + ff_thread_finish_setup(avctx); }else{ //second field int i; @@ -1769,6 +1794,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const int mb_size= 16>>s->avctx->lowres; ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); + MPV_report_decode_progress(s); s->mb_x = 0; s->mb_y += 1<current_picture_ptr; ff_print_debug_info(s, pict); } else { - s->picture_number++; + if (avctx->active_thread_type & FF_THREAD_FRAME) + s->picture_number++; /* latency of 1 frame for I- and P-frames */ /* XXX: use another variable than picture_number */ if (s->last_picture_ptr != NULL) { @@ -2262,7 +2289,7 @@ static int decode_chunks(AVCodecContext *avctx, buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code); if (start_code > 0x1ff){ if(s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT){ - if((avctx->active_thread_type & FF_THREAD_SLICE) && avctx->thread_count > 1){ + if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){ int i; avctx->execute(avctx, slice_decode_thread, &s2->thread_context[0], NULL, s->slice_count, sizeof(void*)); @@ -2430,7 +2457,7 @@ static int decode_chunks(AVCodecContext *avctx, break; } - if((avctx->active_thread_type & FF_THREAD_SLICE) && avctx->thread_count > 1){ + if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){ int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count; if(threshold <= mb_y){ MpegEncContext *thread_context= s2->thread_context[s->slice_count]; @@ -2505,6 +2532,7 @@ AVCodec ff_mpeg1video_decoder = { .flush= flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), + .update_thread_context= ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context) }; AVCodec ff_mpeg2video_decoder = { @@ -2541,7 +2569,7 @@ AVCodec ff_mpegvideo_decoder = { #if CONFIG_MPEG_XVMC_DECODER static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx){ - if((avctx->active_thread_type & FF_THREAD_SLICE) && avctx->thread_count > 1) + if( avctx->active_thread_type & FF_THREAD_SLICE ) return -1; if( !(avctx->slice_flags & SLICE_FLAG_CODED_ORDER) ) return -1; diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 66d4127884..81f09c5a4b 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -23,6 +23,7 @@ #include "mpegvideo.h" #include "mpeg4video.h" #include "h263.h" +#include "thread.h" // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs @@ -373,7 +374,13 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s) return -1; } if(s->pict_type == AV_PICTURE_TYPE_B){ - while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) mb_num++; + int mb_x = 0, mb_y = 0; + + while(s->next_picture.mbskip_table[ s->mb_index2xy[ mb_num ] ]) { + if (!mb_x) ff_thread_await_progress((AVFrame*)s->next_picture_ptr, mb_y++, 0); + mb_num++; + if (++mb_x == s->mb_width) mb_x = 0; + } if(mb_num >= s->mb_num) return -1; // slice contains just skipped MBs which where already decoded } @@ -1303,6 +1310,8 @@ static int mpeg4_decode_mb(MpegEncContext *s, s->last_mv[i][1][0]= s->last_mv[i][1][1]= 0; } + + ff_thread_await_progress((AVFrame*)s->next_picture_ptr, s->mb_y, 0); } /* if we skipped it in the future P Frame than skip it now too */ @@ -1482,6 +1491,12 @@ end: if(s->codec_id==CODEC_ID_MPEG4){ if(mpeg4_is_resync(s)){ const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1; + + if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]){ + ff_thread_await_progress((AVFrame*)s->next_picture_ptr, + (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0); + } + if(s->pict_type==AV_PICTURE_TYPE_B && s->next_picture.mbskip_table[xy + delta]) return SLICE_OK; return SLICE_END; @@ -2235,11 +2250,12 @@ AVCodec ff_mpeg4_decoder = { NULL, ff_h263_decode_end, ff_h263_decode_frame, - CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY, + CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_FRAME_THREADS, .flush= ff_mpeg_flush, .max_lowres= 3, .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"), .pix_fmts= ff_hwaccel_pixfmt_list_420, + .update_thread_context= ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context) }; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index f24e11910a..dfb2289201 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -38,6 +38,7 @@ #include "msmpeg4.h" #include "faandct.h" #include "xvmc_internal.h" +#include "thread.h" #include //#undef NDEBUG @@ -205,7 +206,7 @@ void ff_copy_picture(Picture *dst, Picture *src){ */ static void free_frame_buffer(MpegEncContext *s, Picture *pic) { - s->avctx->release_buffer(s->avctx, (AVFrame*)pic); + ff_thread_release_buffer(s->avctx, (AVFrame*)pic); av_freep(&pic->hwaccel_picture_private); } @@ -227,7 +228,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) } } - r = s->avctx->get_buffer(s->avctx, (AVFrame*)pic); + r = ff_thread_get_buffer(s->avctx, (AVFrame*)pic); if (r<0 || !pic->age || !pic->type || !pic->data[0]) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]); @@ -315,6 +316,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == AV_PICTURE_TYPE_B) pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. + pic->owner2 = NULL; return 0; fail: //for the FF_ALLOCZ_OR_GOTO macro @@ -458,6 +460,81 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src){ //STOP_TIMER("update_duplicate_context") //about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads } +int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) +{ + MpegEncContext *s = dst->priv_data, *s1 = src->priv_data; + + if(dst == src || !s1->context_initialized) return 0; + + //FIXME can parameters change on I-frames? in that case dst may need a reinit + if(!s->context_initialized){ + memcpy(s, s1, sizeof(MpegEncContext)); + + s->avctx = dst; + s->picture_range_start += MAX_PICTURE_COUNT; + s->picture_range_end += MAX_PICTURE_COUNT; + s->bitstream_buffer = NULL; + s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0; + + MPV_common_init(s); + } + + s->avctx->coded_height = s1->avctx->coded_height; + s->avctx->coded_width = s1->avctx->coded_width; + s->avctx->width = s1->avctx->width; + s->avctx->height = s1->avctx->height; + + s->coded_picture_number = s1->coded_picture_number; + s->picture_number = s1->picture_number; + s->input_picture_number = s1->input_picture_number; + + memcpy(s->picture, s1->picture, s1->picture_count * sizeof(Picture)); + memcpy(&s->last_picture, &s1->last_picture, (char*)&s1->last_picture_ptr - (char*)&s1->last_picture); + + s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1); + s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1); + s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1); + + memcpy(s->prev_pict_types, s1->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE); + + //Error/bug resilience + s->next_p_frame_damaged = s1->next_p_frame_damaged; + s->workaround_bugs = s1->workaround_bugs; + + //MPEG4 timing info + memcpy(&s->time_increment_bits, &s1->time_increment_bits, (char*)&s1->shape - (char*)&s1->time_increment_bits); + + //B-frame info + s->max_b_frames = s1->max_b_frames; + s->low_delay = s1->low_delay; + s->dropable = s1->dropable; + + //DivX handling (doesn't work) + s->divx_packed = s1->divx_packed; + + if(s1->bitstream_buffer){ + if (s1->bitstream_buffer_size + FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size) + av_fast_malloc(&s->bitstream_buffer, &s->allocated_bitstream_buffer_size, s1->allocated_bitstream_buffer_size); + s->bitstream_buffer_size = s1->bitstream_buffer_size; + memcpy(s->bitstream_buffer, s1->bitstream_buffer, s1->bitstream_buffer_size); + memset(s->bitstream_buffer+s->bitstream_buffer_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + } + + //MPEG2/interlacing info + memcpy(&s->progressive_sequence, &s1->progressive_sequence, (char*)&s1->rtp_mode - (char*)&s1->progressive_sequence); + + if(!s1->first_field){ + s->last_pict_type= s1->pict_type; + if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->quality; + + if(s1->pict_type!=FF_B_TYPE){ + s->last_non_b_pict_type= s1->pict_type; + } + } + + return 0; +} + /** * sets the given MpegEncContext to common defaults (same for encoding and decoding). * the changed fields will not depend upon the prior state of the MpegEncContext. @@ -478,6 +555,9 @@ void MPV_common_defaults(MpegEncContext *s){ s->f_code = 1; s->b_code = 1; + + s->picture_range_start = 0; + s->picture_range_end = MAX_PICTURE_COUNT; } /** @@ -506,7 +586,8 @@ av_cold int MPV_common_init(MpegEncContext *s) return -1; } - if(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height)){ + if((s->avctx->active_thread_type & FF_THREAD_SLICE) && + (s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height))){ av_log(s->avctx, AV_LOG_ERROR, "too many threads\n"); return -1; } @@ -602,8 +683,9 @@ av_cold int MPV_common_init(MpegEncContext *s) } } - FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, MAX_PICTURE_COUNT * sizeof(Picture), fail) - for(i = 0; i < MAX_PICTURE_COUNT; i++) { + s->picture_count = MAX_PICTURE_COUNT * FFMAX(1, s->avctx->thread_count); + FF_ALLOCZ_OR_GOTO(s->avctx, s->picture, s->picture_count * sizeof(Picture), fail) + for(i = 0; i < s->picture_count; i++) { avcodec_get_frame_defaults((AVFrame *)&s->picture[i]); } @@ -665,9 +747,10 @@ av_cold int MPV_common_init(MpegEncContext *s) } s->context_initialized = 1; + s->thread_context[0]= s; if (s->width && s->height) { - s->thread_context[0]= s; + if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE) { threads = s->avctx->thread_count; for(i=1; ithread_context[i]->start_mb_y= (s->mb_height*(i ) + s->avctx->thread_count/2) / s->avctx->thread_count; s->thread_context[i]->end_mb_y = (s->mb_height*(i+1) + s->avctx->thread_count/2) / s->avctx->thread_count; } + } else { + if(init_duplicate_context(s, s) < 0) goto fail; + s->start_mb_y = 0; + s->end_mb_y = s->mb_height; + } } return 0; @@ -694,12 +782,14 @@ void MPV_common_end(MpegEncContext *s) { int i, j, k; - for(i=0; iavctx->thread_count; i++){ - free_duplicate_context(s->thread_context[i]); - } - for(i=1; iavctx->thread_count; i++){ - av_freep(&s->thread_context[i]); - } + if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_SLICE) { + for(i=0; iavctx->thread_count; i++){ + free_duplicate_context(s->thread_context[i]); + } + for(i=1; iavctx->thread_count; i++){ + av_freep(&s->thread_context[i]); + } + } else free_duplicate_context(s); av_freep(&s->parse_context.buffer); s->parse_context.buffer_size=0; @@ -754,8 +844,8 @@ void MPV_common_end(MpegEncContext *s) av_freep(&s->reordered_input_picture); av_freep(&s->dct_offset); - if(s->picture){ - for(i=0; ipicture && !s->avctx->is_copy){ + for(i=0; ipicture_count; i++){ free_picture(s, &s->picture[i]); } } @@ -769,7 +859,8 @@ void MPV_common_end(MpegEncContext *s) for(i=0; i<3; i++) av_freep(&s->visualization_buffer[i]); - avcodec_default_free_buffers(s->avctx); + if(!(s->avctx->active_thread_type&FF_THREAD_FRAME)) + avcodec_default_free_buffers(s->avctx); } void init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]) @@ -863,18 +954,33 @@ void init_vlc_rl(RLTable *rl) } } +void ff_release_unused_pictures(MpegEncContext *s, int remove_current) +{ + int i; + + /* release non reference frames */ + for(i=0; ipicture_count; i++){ + if(s->picture[i].data[0] && !s->picture[i].reference + && (!s->picture[i].owner2 || s->picture[i].owner2 == s) + && (remove_current || &s->picture[i] != s->current_picture_ptr) + /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ + free_frame_buffer(s, &s->picture[i]); + } + } +} + int ff_find_unused_picture(MpegEncContext *s, int shared){ int i; if(shared){ - for(i=0; ipicture_range_start; ipicture_range_end; i++){ if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i; } }else{ - for(i=0; ipicture_range_start; ipicture_range_end; i++){ if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME } - for(i=0; ipicture_range_start; ipicture_range_end; i++){ if(s->picture[i].data[0]==NULL) return i; } } @@ -931,7 +1037,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) /* release forgotten pictures */ /* if(mpeg124/h263) */ if(!s->encoding){ - for(i=0; ipicture_count; i++){ if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){ av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n"); free_frame_buffer(s, &s->picture[i]); @@ -942,12 +1048,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) } if(!s->encoding){ - /* release non reference frames */ - for(i=0; ipicture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ - free_frame_buffer(s, &s->picture[i]); - } - } + ff_release_unused_pictures(s, 1); if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL) pic= s->current_picture_ptr; //we already have a unused image (maybe it was set before reading the header) @@ -977,6 +1078,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field; } s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence; + s->current_picture_ptr->field_picture= s->picture_structure != PICT_FRAME; } s->current_picture_ptr->pict_type= s->pict_type; @@ -1010,6 +1112,8 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->last_picture_ptr= &s->picture[i]; if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) return -1; + ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0); + ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1); } if((s->next_picture_ptr==NULL || s->next_picture_ptr->data[0]==NULL) && s->pict_type==AV_PICTURE_TYPE_B){ /* Allocate a dummy frame */ @@ -1017,6 +1121,8 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->next_picture_ptr= &s->picture[i]; if(ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) return -1; + ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 0); + ff_thread_report_progress((AVFrame*)s->next_picture_ptr, INT_MAX, 1); } } @@ -1068,11 +1174,12 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) void MPV_frame_end(MpegEncContext *s) { int i; - /* draw edge for correct motion prediction if outside */ + /* redraw edges for the frame if decoding didn't complete */ //just to make sure that all data is rendered. if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){ ff_xvmc_field_end(s); - }else if(!s->avctx->hwaccel + }else if((s->error_count || s->encoding) + && !s->avctx->hwaccel && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) && s->unrestricted_mv && s->current_picture.reference @@ -1088,6 +1195,7 @@ void MPV_frame_end(MpegEncContext *s) s->h_edge_pos>>1, s->v_edge_pos>>1, EDGE_WIDTH/2, EDGE_TOP | EDGE_BOTTOM); } + emms_c(); s->last_pict_type = s->pict_type; @@ -1108,7 +1216,7 @@ void MPV_frame_end(MpegEncContext *s) if(s->encoding){ /* release non-reference frames */ - for(i=0; ipicture_count; i++){ if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ free_frame_buffer(s, &s->picture[i]); } @@ -1121,6 +1229,10 @@ void MPV_frame_end(MpegEncContext *s) memset(&s->current_picture, 0, sizeof(Picture)); #endif s->avctx->coded_frame= (AVFrame*)s->current_picture_ptr; + + if (s->codec_id != CODEC_ID_H264 && s->current_picture.reference) { + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_height-1, 0); + } } /** @@ -1785,6 +1897,43 @@ static inline void MPV_motion_lowres(MpegEncContext *s, } } +/** + * find the lowest MB row referenced in the MVs + */ +int MPV_lowest_referenced_row(MpegEncContext *s, int dir) +{ + int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample; + int my, off, i, mvs; + + if (s->picture_structure != PICT_FRAME) goto unhandled; + + switch (s->mv_type) { + case MV_TYPE_16X16: + mvs = 1; + break; + case MV_TYPE_16X8: + mvs = 2; + break; + case MV_TYPE_8X8: + mvs = 4; + break; + default: + goto unhandled; + } + + for (i = 0; i < mvs; i++) { + my = s->mv[dir][i][1]<> 6; + + return FFMIN(FFMAX(s->mb_y + off, 0), s->mb_height-1); +unhandled: + return s->mb_height-1; +} + /* put block[] to dest[] */ static inline void put_dct(MpegEncContext *s, DCTELEM *block, int i, uint8_t *dest, int line_size, int qscale) @@ -1949,6 +2098,16 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], /* motion handling */ /* decoding or more than one mb_type (MC was already done otherwise) */ if(!s->encoding){ + + if(HAVE_PTHREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { + if (s->mv_dir & MV_DIR_FORWARD) { + ff_thread_await_progress((AVFrame*)s->last_picture_ptr, MPV_lowest_referenced_row(s, 0), 0); + } + if (s->mv_dir & MV_DIR_BACKWARD) { + ff_thread_await_progress((AVFrame*)s->next_picture_ptr, MPV_lowest_referenced_row(s, 1), 0); + } + } + if(lowres_flag){ h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab; @@ -2112,19 +2271,37 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]){ * @param h is the normal height, this will be reduced automatically if needed for the last row */ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){ + const int field_pic= s->picture_structure != PICT_FRAME; + if(field_pic){ + h <<= 1; + y <<= 1; + } + + if (!s->avctx->hwaccel + && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) + && s->unrestricted_mv + && s->current_picture.reference + && !s->intra_only + && !(s->flags&CODEC_FLAG_EMU_EDGE)) { + int sides = 0, edge_h; + if (y==0) sides |= EDGE_TOP; + if (y + h >= s->v_edge_pos) sides |= EDGE_BOTTOM; + + edge_h= FFMIN(h, s->v_edge_pos - y); + + s->dsp.draw_edges(s->current_picture_ptr->data[0] + y *s->linesize , s->linesize , s->h_edge_pos , edge_h , EDGE_WIDTH , sides); + s->dsp.draw_edges(s->current_picture_ptr->data[1] + (y>>1)*s->uvlinesize, s->uvlinesize, s->h_edge_pos>>1, edge_h>>1, EDGE_WIDTH/2, sides); + s->dsp.draw_edges(s->current_picture_ptr->data[2] + (y>>1)*s->uvlinesize, s->uvlinesize, s->h_edge_pos>>1, edge_h>>1, EDGE_WIDTH/2, sides); + } + + h= FFMIN(h, s->avctx->height - y); + + if(field_pic && s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return; + if (s->avctx->draw_horiz_band) { AVFrame *src; - const int field_pic= s->picture_structure != PICT_FRAME; int offset[4]; - h= FFMIN(h, (s->avctx->height>>field_pic) - y); - - if(field_pic && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)){ - h <<= 1; - y <<= 1; - if(s->first_field) return; - } - if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) src= (AVFrame*)s->current_picture_ptr; else if(s->last_picture_ptr) @@ -2190,7 +2367,7 @@ void ff_mpeg_flush(AVCodecContext *avctx){ if(s==NULL || s->picture==NULL) return; - for(i=0; ipicture_count; i++){ if(s->picture[i].data[0] && ( s->picture[i].type == FF_BUFFER_TYPE_INTERNAL || s->picture[i].type == FF_BUFFER_TYPE_USER)) free_frame_buffer(s, &s->picture[i]); @@ -2444,3 +2621,9 @@ void ff_set_qscale(MpegEncContext * s, int qscale) s->y_dc_scale= s->y_dc_scale_table[ qscale ]; s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ]; } + +void MPV_report_decode_progress(MpegEncContext *s) +{ + if (s->pict_type != FF_B_TYPE && !s->partitioned_frame && !s->error_occurred) + ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_y, 0); +} diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 6d5ab19283..6ce7faa235 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -76,6 +76,8 @@ enum OutputFormat { #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2 +struct MpegEncContext; + /** * Picture. */ @@ -123,6 +125,7 @@ typedef struct Picture{ int ref_poc[2][2][16]; ///< h264 POCs of the frames used as reference (FIXME need per slice) int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice) int mbaff; ///< h264 1 -> MBAFF frame 0-> not MBAFF + int field_picture; ///< whether or not the picture was encoded in seperate fields int mb_var_sum; ///< sum of MB variance for current frame int mc_mb_var_sum; ///< motion compensated MB variance for current frame @@ -131,10 +134,9 @@ typedef struct Picture{ uint8_t *mb_mean; ///< Table for MB luminance int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decision FIXME remove int b_frame_score; /* */ + struct MpegEncContext *owner2; ///< pointer to the MpegEncContext that allocated this picture } Picture; -struct MpegEncContext; - /** * Motion estimation context. */ @@ -291,6 +293,8 @@ typedef struct MpegEncContext { Picture *last_picture_ptr; ///< pointer to the previous picture. Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred) Picture *current_picture_ptr; ///< pointer to the current picture + int picture_count; ///< number of allocated pictures (MAX_PICTURE_COUNT * avctx->thread_count) + int picture_range_start, picture_range_end; ///< the part of picture that this context can allocate in uint8_t *visualization_buffer[3]; //< temporary buffer vor MV visualization int last_dc[3]; ///< last DC values for MPEG1 int16_t *dc_val_base; @@ -470,7 +474,7 @@ typedef struct MpegEncContext { int last_bits; ///< temp var used for calculating the above vars /* error concealment / resync */ - int error_count; + int error_count, error_occurred; uint8_t *error_status_table; ///< table of the error status of each MB #define VP_START 1 ///< current MB is the first after a resync marker #define AC_ERROR 2 @@ -677,6 +681,10 @@ typedef struct MpegEncContext { void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block); } MpegEncContext; +#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \ + (pic >= old_ctx->picture && pic < old_ctx->picture+old_ctx->picture_count ?\ + &new_ctx->picture[pic - old_ctx->picture] : pic - (Picture*)old_ctx + (Picture*)new_ctx)\ + : NULL) void MPV_decode_defaults(MpegEncContext *s); int MPV_common_init(MpegEncContext *s); @@ -699,9 +707,13 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h); void ff_mpeg_flush(AVCodecContext *avctx); void ff_print_debug_info(MpegEncContext *s, AVFrame *pict); void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); +void ff_release_unused_pictures(MpegEncContext *s, int remove_current); int ff_find_unused_picture(MpegEncContext *s, int shared); void ff_denoise_dct(MpegEncContext *s, DCTELEM *block); void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); +int MPV_lowest_referenced_row(MpegEncContext *s, int dir); +void MPV_report_decode_progress(MpegEncContext *s); +int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); void ff_set_qscale(MpegEncContext * s, int qscale); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a212149189..237ea64790 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -36,6 +36,7 @@ #include "mjpegenc.h" #include "msmpeg4.h" #include "faandct.h" +#include "thread.h" #include "aandcttab.h" #include "flv.h" #include "mpeg4video.h" @@ -1225,9 +1226,9 @@ int MPV_encode_picture(AVCodecContext *avctx, { MpegEncContext *s = avctx->priv_data; AVFrame *pic_arg = data; - int i, stuffing_count; + int i, stuffing_count, context_count = avctx->active_thread_type&FF_THREAD_SLICE ? avctx->thread_count : 1; - for(i=0; ithread_count; i++){ + for(i=0; ithread_context[i]->start_mb_y; int end_y= s->thread_context[i]-> end_mb_y; int h= s->mb_height; @@ -1291,7 +1292,7 @@ vbv_retry: s->last_non_b_time= s->time - s->pp_time; } // av_log(NULL, AV_LOG_ERROR, "R:%d ", s->next_lambda); - for(i=0; ithread_count; i++){ + for(i=0; ithread_context[i]->pb; init_put_bits(pb, pb->buf, pb->buf_end - pb->buf); } @@ -2758,6 +2759,7 @@ static int encode_picture(MpegEncContext *s, int picture_number) { int i; int bits; + int context_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1; s->picture_number = picture_number; @@ -2797,7 +2799,7 @@ static int encode_picture(MpegEncContext *s, int picture_number) } s->mb_intra=0; //for the rate distortion & bit compare functions - for(i=1; iavctx->thread_count; i++){ + for(i=1; ithread_context[i], s); } @@ -2810,11 +2812,11 @@ static int encode_picture(MpegEncContext *s, int picture_number) s->lambda2= (s->lambda2* (int64_t)s->avctx->me_penalty_compensation + 128)>>8; if(s->pict_type != AV_PICTURE_TYPE_B && s->avctx->me_threshold==0){ if((s->avctx->pre_me && s->last_non_b_pict_type==AV_PICTURE_TYPE_I) || s->avctx->pre_me==2){ - s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*)); + s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } } - s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*)); + s->avctx->execute(s->avctx, estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); }else /* if(s->pict_type == AV_PICTURE_TYPE_I) */{ /* I-Frame */ for(i=0; imb_stride*s->mb_height; i++) @@ -2822,10 +2824,10 @@ static int encode_picture(MpegEncContext *s, int picture_number) if(!s->fixed_qscale){ /* finding spatial complexity for I-frame rate control */ - s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*)); + s->avctx->execute(s->avctx, mb_var_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); } } - for(i=1; iavctx->thread_count; i++){ + for(i=1; ithread_context[i]); } s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp; @@ -2961,11 +2963,11 @@ static int encode_picture(MpegEncContext *s, int picture_number) bits= put_bits_count(&s->pb); s->header_bits= bits - s->last_bits; - for(i=1; iavctx->thread_count; i++){ + for(i=1; ithread_context[i], s); } - s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, s->avctx->thread_count, sizeof(void*)); - for(i=1; iavctx->thread_count; i++){ + s->avctx->execute(s->avctx, encode_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); + for(i=1; ithread_context[i]); } emms_c(); diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 0de876087b..08ef4ba0c2 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -55,7 +55,7 @@ typedef struct ThreadContext { } ThreadContext; /// Max number of frame buffers that can be allocated when using frame threads. -#define MAX_BUFFERS 32 +#define MAX_BUFFERS (32+1) /** * Context used by codec threads and stored in their AVCodecContext thread_opaque. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9e879940a9..0eb5afd63c 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -115,7 +115,7 @@ typedef struct InternalBuffer{ enum PixelFormat pix_fmt; }InternalBuffer; -#define INTERNAL_BUFFER_SIZE 32 +#define INTERNAL_BUFFER_SIZE (32+1) void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){ int w_align= 1; @@ -360,6 +360,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ assert(pic->type==FF_BUFFER_TYPE_INTERNAL); assert(s->internal_buffer_count); + if(s->internal_buffer){ buf = NULL; /* avoids warning */ for(i=0; iinternal_buffer_count; i++){ //just 3-5 checks so is not worth to optimize buf= &((InternalBuffer*)s->internal_buffer)[i]; @@ -371,6 +372,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ last = &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count]; FFSWAP(InternalBuffer, *buf, *last); + } for(i=0; i<4; i++){ pic->data[i]=NULL; diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak index 5e6ff50e84..969bf413e4 100644 --- a/tests/fate/h264.mak +++ b/tests/fate/h264.mak @@ -179,23 +179,23 @@ FATE_H264 := $(FATE_H264:%=fate-h264-conformance-%) \ FATE_TESTS += $(FATE_H264) fate-h264: $(FATE_H264) -fate-h264-conformance-aud_mw_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/AUD_MW_E.264 -fate-h264-conformance-ba1_ft_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/BA1_FT_C.264 -fate-h264-conformance-ba1_sony_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/BA1_Sony_D.jsv -fate-h264-conformance-ba2_sony_f: CMD = framecrc -i $(SAMPLES)/h264-conformance/BA2_Sony_F.jsv +fate-h264-conformance-aud_mw_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/AUD_MW_E.264 +fate-h264-conformance-ba1_ft_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BA1_FT_C.264 +fate-h264-conformance-ba1_sony_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BA1_Sony_D.jsv +fate-h264-conformance-ba2_sony_f: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BA2_Sony_F.jsv fate-h264-conformance-ba3_sva_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/BA3_SVA_C.264 -fate-h264-conformance-ba_mw_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/BA_MW_D.264 -fate-h264-conformance-bamq1_jvc_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/BAMQ1_JVC_C.264 -fate-h264-conformance-bamq2_jvc_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/BAMQ2_JVC_C.264 -fate-h264-conformance-banm_mw_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/BANM_MW_D.264 -fate-h264-conformance-basqp1_sony_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/BASQP1_Sony_C.jsv -fate-h264-conformance-caba1_sony_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/CABA1_Sony_D.jsv -fate-h264-conformance-caba1_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CABA1_SVA_B.264 -fate-h264-conformance-caba2_sony_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CABA2_Sony_E.jsv -fate-h264-conformance-caba2_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CABA2_SVA_B.264 +fate-h264-conformance-ba_mw_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BA_MW_D.264 +fate-h264-conformance-bamq1_jvc_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BAMQ1_JVC_C.264 +fate-h264-conformance-bamq2_jvc_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BAMQ2_JVC_C.264 +fate-h264-conformance-banm_mw_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BANM_MW_D.264 +fate-h264-conformance-basqp1_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/BASQP1_Sony_C.jsv +fate-h264-conformance-caba1_sony_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CABA1_Sony_D.jsv +fate-h264-conformance-caba1_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CABA1_SVA_B.264 +fate-h264-conformance-caba2_sony_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CABA2_Sony_E.jsv +fate-h264-conformance-caba2_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CABA2_SVA_B.264 fate-h264-conformance-caba3_sony_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CABA3_Sony_C.jsv fate-h264-conformance-caba3_sva_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CABA3_SVA_B.264 -fate-h264-conformance-caba3_toshiba_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CABA3_TOSHIBA_E.264 +fate-h264-conformance-caba3_toshiba_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CABA3_TOSHIBA_E.264 fate-h264-conformance-cabac_mot_fld0_full: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/camp_mot_fld0_full.26l fate-h264-conformance-cabac_mot_frm0_full: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/camp_mot_frm0_full.26l fate-h264-conformance-cabac_mot_mbaff0_full: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/camp_mot_mbaff0_full.26l @@ -206,7 +206,7 @@ fate-h264-conformance-cabastbr3_sony_b: CMD = framecrc -vsync 0 -strict 1 -i $( fate-h264-conformance-cabref3_sand_d: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CABREF3_Sand_D.264 fate-h264-conformance-cacqp3_sony_d: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CACQP3_Sony_D.jsv fate-h264-conformance-cafi1_sva_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAFI1_SVA_C.264 -fate-h264-conformance-cama1_sony_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CAMA1_Sony_C.jsv +fate-h264-conformance-cama1_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CAMA1_Sony_C.jsv fate-h264-conformance-cama1_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAMA1_TOSHIBA_B.264 fate-h264-conformance-cama1_vtc_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/cama1_vtc_c.avc fate-h264-conformance-cama2_vtc_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/cama2_vtc_b.avc @@ -219,37 +219,37 @@ fate-h264-conformance-camanl3_sand_e: CMD = framecrc -vsync 0 -strict 1 -i $(SA fate-h264-conformance-camasl3_sony_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAMASL3_Sony_B.jsv fate-h264-conformance-camp_mot_mbaff_l30: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAMP_MOT_MBAFF_L30.26l fate-h264-conformance-camp_mot_mbaff_l31: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAMP_MOT_MBAFF_L31.26l -fate-h264-conformance-canl1_sony_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL1_Sony_E.jsv -fate-h264-conformance-canl1_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL1_SVA_B.264 -fate-h264-conformance-canl1_toshiba_g: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL1_TOSHIBA_G.264 -fate-h264-conformance-canl2_sony_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL2_Sony_E.jsv -fate-h264-conformance-canl2_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL2_SVA_B.264 +fate-h264-conformance-canl1_sony_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL1_Sony_E.jsv +fate-h264-conformance-canl1_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL1_SVA_B.264 +fate-h264-conformance-canl1_toshiba_g: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL1_TOSHIBA_G.264 +fate-h264-conformance-canl2_sony_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL2_Sony_E.jsv +fate-h264-conformance-canl2_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL2_SVA_B.264 fate-h264-conformance-canl3_sony_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CANL3_Sony_C.jsv -fate-h264-conformance-canl3_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL3_SVA_B.264 -fate-h264-conformance-canl4_sva_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANL4_SVA_B.264 -fate-h264-conformance-canlma2_sony_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANLMA2_Sony_C.jsv -fate-h264-conformance-canlma3_sony_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CANLMA3_Sony_C.jsv +fate-h264-conformance-canl3_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL3_SVA_B.264 +fate-h264-conformance-canl4_sva_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANL4_SVA_B.264 +fate-h264-conformance-canlma2_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANLMA2_Sony_C.jsv +fate-h264-conformance-canlma3_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CANLMA3_Sony_C.jsv fate-h264-conformance-capa1_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAPA1_TOSHIBA_B.264 fate-h264-conformance-capama3_sand_f: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAPAMA3_Sand_F.264 -fate-h264-conformance-capcm1_sand_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CAPCM1_Sand_E.264 -fate-h264-conformance-capcmnl1_sand_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CAPCMNL1_Sand_E.264 +fate-h264-conformance-capcm1_sand_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CAPCM1_Sand_E.264 +fate-h264-conformance-capcmnl1_sand_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CAPCMNL1_Sand_E.264 fate-h264-conformance-capm3_sony_d: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAPM3_Sony_D.jsv -fate-h264-conformance-caqp1_sony_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CAQP1_Sony_B.jsv +fate-h264-conformance-caqp1_sony_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CAQP1_Sony_B.jsv fate-h264-conformance-cavlc_mot_fld0_full_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/cvmp_mot_fld0_full_B.26l fate-h264-conformance-cavlc_mot_frm0_full_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/cvmp_mot_frm0_full_B.26l fate-h264-conformance-cavlc_mot_mbaff0_full_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/cvmp_mot_mbaff0_full_B.26l fate-h264-conformance-cavlc_mot_picaff0_full_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/cvmp_mot_picaff0_full_B.26l -fate-h264-conformance-cawp1_toshiba_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CAWP1_TOSHIBA_E.264 +fate-h264-conformance-cawp1_toshiba_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CAWP1_TOSHIBA_E.264 fate-h264-conformance-cawp5_toshiba_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CAWP5_TOSHIBA_E.264 -fate-h264-conformance-ci1_ft_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/CI1_FT_B.264 -fate-h264-conformance-ci_mw_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/CI_MW_D.264 +fate-h264-conformance-ci1_ft_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CI1_FT_B.264 +fate-h264-conformance-ci_mw_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CI_MW_D.264 fate-h264-conformance-cvbs3_sony_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVBS3_Sony_C.jsv -fate-h264-conformance-cvcanlma2_sony_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CVCANLMA2_Sony_C.jsv +fate-h264-conformance-cvcanlma2_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVCANLMA2_Sony_C.jsv fate-h264-conformance-cvfi1_sony_d: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVFI1_Sony_D.jsv fate-h264-conformance-cvfi1_sva_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVFI1_SVA_C.264 fate-h264-conformance-cvfi2_sony_h: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVFI2_Sony_H.jsv fate-h264-conformance-cvfi2_sva_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVFI2_SVA_C.264 -fate-h264-conformance-cvma1_sony_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/CVMA1_Sony_D.jsv +fate-h264-conformance-cvma1_sony_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVMA1_Sony_D.jsv fate-h264-conformance-cvma1_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVMA1_TOSHIBA_B.264 fate-h264-conformance-cvmanl1_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVMANL1_TOSHIBA_B.264 fate-h264-conformance-cvmanl2_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVMANL2_TOSHIBA_B.264 @@ -261,68 +261,68 @@ fate-h264-conformance-cvmp_mot_frm_l31_b: CMD = framecrc -vsync 0 -strict 1 -i fate-h264-conformance-cvnlfi1_sony_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVNLFI1_Sony_C.jsv fate-h264-conformance-cvnlfi2_sony_h: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVNLFI2_Sony_H.jsv fate-h264-conformance-cvpa1_toshiba_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVPA1_TOSHIBA_B.264 -fate-h264-conformance-cvpcmnl1_sva_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CVPCMNL1_SVA_C.264 -fate-h264-conformance-cvpcmnl2_sva_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/CVPCMNL2_SVA_C.264 -fate-h264-conformance-cvwp1_toshiba_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/CVWP1_TOSHIBA_E.264 +fate-h264-conformance-cvpcmnl1_sva_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVPCMNL1_SVA_C.264 +fate-h264-conformance-cvpcmnl2_sva_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVPCMNL2_SVA_C.264 +fate-h264-conformance-cvwp1_toshiba_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/CVWP1_TOSHIBA_E.264 fate-h264-conformance-cvwp2_toshiba_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVWP2_TOSHIBA_E.264 fate-h264-conformance-cvwp3_toshiba_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVWP3_TOSHIBA_E.264 fate-h264-conformance-cvwp5_toshiba_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/CVWP5_TOSHIBA_E.264 fate-h264-conformance-fi1_sony_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FI1_Sony_E.jsv -fate-h264-conformance-frext-alphaconformanceg: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/test8b43.264 -fate-h264-conformance-frext-bcrm_freh10: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh10.264 -vsync 0 -fate-h264-conformance-frext-brcm_freh11: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh11.264 -vsync 0 -fate-h264-conformance-frext-brcm_freh3: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh3.264 -fate-h264-conformance-frext-brcm_freh4: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh4.264 -vsync 0 -fate-h264-conformance-frext-brcm_freh5: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh5.264 -fate-h264-conformance-frext-brcm_freh8: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh8.264 -fate-h264-conformance-frext-brcm_freh9: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh9.264 -fate-h264-conformance-frext-freh12_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/Freh12_B.264 -fate-h264-conformance-frext-freh1_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/Freh1_B.264 -fate-h264-conformance-frext-freh2_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/Freh2_B.264 -fate-h264-conformance-frext-freh6: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/freh6.264 -vsync 0 -fate-h264-conformance-frext-freh7_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/Freh7_B.264 -vsync 0 -fate-h264-conformance-frext-frext01_jvc_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FREXT01_JVC_D.264 -fate-h264-conformance-frext-frext02_jvc_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FREXT02_JVC_C.264 -fate-h264-conformance-frext-frext1_panasonic_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FRExt1_Panasonic.avc -fate-h264-conformance-frext-frext2_panasonic_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FRExt2_Panasonic.avc -vsync 0 -fate-h264-conformance-frext-frext3_panasonic_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FRExt3_Panasonic.avc -fate-h264-conformance-frext-frext4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/FRExt4_Panasonic.avc +fate-h264-conformance-frext-alphaconformanceg: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/test8b43.264 +fate-h264-conformance-frext-bcrm_freh10: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh10.264 -vsync 0 +fate-h264-conformance-frext-brcm_freh11: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh11.264 -vsync 0 +fate-h264-conformance-frext-brcm_freh3: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh3.264 +fate-h264-conformance-frext-brcm_freh4: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh4.264 -vsync 0 +fate-h264-conformance-frext-brcm_freh5: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh5.264 +fate-h264-conformance-frext-brcm_freh8: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh8.264 +fate-h264-conformance-frext-brcm_freh9: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh9.264 +fate-h264-conformance-frext-freh12_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/Freh12_B.264 +fate-h264-conformance-frext-freh1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/Freh1_B.264 +fate-h264-conformance-frext-freh2_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/Freh2_B.264 +fate-h264-conformance-frext-freh6: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/freh6.264 -vsync 0 +fate-h264-conformance-frext-freh7_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/Freh7_B.264 -vsync 0 +fate-h264-conformance-frext-frext01_jvc_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FREXT01_JVC_D.264 +fate-h264-conformance-frext-frext02_jvc_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FREXT02_JVC_C.264 +fate-h264-conformance-frext-frext1_panasonic_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FRExt1_Panasonic.avc +fate-h264-conformance-frext-frext2_panasonic_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FRExt2_Panasonic.avc -vsync 0 +fate-h264-conformance-frext-frext3_panasonic_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FRExt3_Panasonic.avc +fate-h264-conformance-frext-frext4_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FRExt4_Panasonic.avc fate-h264-conformance-frext-frext_mmco4_sony_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/FRExt_MMCO4_Sony_B.264 -fate-h264-conformance-frext-hcaff1_hhi_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAFF1_HHI.264 -fate-h264-conformance-frext-hcafr1_hhi_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAFR1_HHI.264 -fate-h264-conformance-frext-hcafr2_hhi_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAFR2_HHI.264 -fate-h264-conformance-frext-hcafr3_hhi_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAFR3_HHI.264 -fate-h264-conformance-frext-hcafr4_hhi_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAFR4_HHI.264 -fate-h264-conformance-frext-hcamff1_hhi_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HCAMFF1_HHI.264 -fate-h264-conformance-frext-hpca_brcm_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCA_BRCM_C.264 -fate-h264-conformance-frext-hpcadq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCADQ_BRCM_B.264 -fate-h264-conformance-frext-hpcafl_bcrm_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCAFL_BRCM_C.264 -vsync 0 -fate-h264-conformance-frext-hpcaflnl_bcrm_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCAFLNL_BRCM_C.264 -vsync 0 -fate-h264-conformance-frext-hpcalq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCALQ_BRCM_B.264 -fate-h264-conformance-frext-hpcamapalq_bcrm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCAMAPALQ_BRCM_B.264 -vsync 0 -fate-h264-conformance-frext-hpcamolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCAMOLQ_BRCM_B.264 -fate-h264-conformance-frext-hpcanl_brcm_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCANL_BRCM_C.264 -fate-h264-conformance-frext-hpcaq2lq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCAQ2LQ_BRCM_B.264 -fate-h264-conformance-frext-hpcv_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCV_BRCM_A.264 -fate-h264-conformance-frext-hpcvfl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFL_BRCM_A.264 -vsync 0 -fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0 -fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264 -fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264 -fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264 -pix_fmt yuv420p10le -fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-hcaff1_hhi_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAFF1_HHI.264 +fate-h264-conformance-frext-hcafr1_hhi_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAFR1_HHI.264 +fate-h264-conformance-frext-hcafr2_hhi_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAFR2_HHI.264 +fate-h264-conformance-frext-hcafr3_hhi_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAFR3_HHI.264 +fate-h264-conformance-frext-hcafr4_hhi_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAFR4_HHI.264 +fate-h264-conformance-frext-hcamff1_hhi_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HCAMFF1_HHI.264 +fate-h264-conformance-frext-hpca_brcm_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCA_BRCM_C.264 +fate-h264-conformance-frext-hpcadq_brcm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCADQ_BRCM_B.264 +fate-h264-conformance-frext-hpcafl_bcrm_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCAFL_BRCM_C.264 -vsync 0 +fate-h264-conformance-frext-hpcaflnl_bcrm_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCAFLNL_BRCM_C.264 -vsync 0 +fate-h264-conformance-frext-hpcalq_brcm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCALQ_BRCM_B.264 +fate-h264-conformance-frext-hpcamapalq_bcrm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCAMAPALQ_BRCM_B.264 -vsync 0 +fate-h264-conformance-frext-hpcamolq_brcm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCAMOLQ_BRCM_B.264 +fate-h264-conformance-frext-hpcanl_brcm_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCANL_BRCM_C.264 +fate-h264-conformance-frext-hpcaq2lq_brcm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCAQ2LQ_BRCM_B.264 +fate-h264-conformance-frext-hpcv_brcm_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCV_BRCM_A.264 +fate-h264-conformance-frext-hpcvfl_bcrm_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCVFL_BRCM_A.264 -vsync 0 +fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0 +fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264 +fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264 +fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264 -pix_fmt yuv420p10le fate-h264-conformance-hcbp2_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCBP2_HHI_A.264 fate-h264-conformance-hcmp1_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCMP1_HHI_A.264 -fate-h264-conformance-ls_sva_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/LS_SVA_D.264 -fate-h264-conformance-midr_mw_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/MIDR_MW_D.264 -fate-h264-conformance-mps_mw_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/MPS_MW_A.264 -fate-h264-conformance-mr1_bt_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/MR1_BT_A.h264 -fate-h264-conformance-mr1_mw_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/MR1_MW_A.264 -fate-h264-conformance-mr2_mw_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/MR2_MW_A.264 +fate-h264-conformance-ls_sva_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/LS_SVA_D.264 +fate-h264-conformance-midr_mw_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MIDR_MW_D.264 +fate-h264-conformance-mps_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MPS_MW_A.264 +fate-h264-conformance-mr1_bt_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR1_BT_A.h264 +fate-h264-conformance-mr1_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR1_MW_A.264 +fate-h264-conformance-mr2_mw_a: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/MR2_MW_A.264 fate-h264-conformance-mr2_tandberg_e: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR2_TANDBERG_E.264 fate-h264-conformance-mr3_tandberg_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR3_TANDBERG_B.264 fate-h264-conformance-mr4_tandberg_c: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR4_TANDBERG_C.264 @@ -332,26 +332,26 @@ fate-h264-conformance-mr7_bt_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES) fate-h264-conformance-mr8_bt_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR8_BT_B.h264 fate-h264-conformance-mr9_bt_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/MR9_BT_B.h264 fate-h264-conformance-mv1_brcm_d: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/src19td.IBP.264 -fate-h264-conformance-nl1_sony_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/NL1_Sony_D.jsv -fate-h264-conformance-nl2_sony_h: CMD = framecrc -i $(SAMPLES)/h264-conformance/NL2_Sony_H.jsv -fate-h264-conformance-nl3_sva_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/NL3_SVA_E.264 -fate-h264-conformance-nlmq1_jvc_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/NLMQ1_JVC_C.264 -fate-h264-conformance-nlmq2_jvc_c: CMD = framecrc -i $(SAMPLES)/h264-conformance/NLMQ2_JVC_C.264 -fate-h264-conformance-nrf_mw_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/NRF_MW_E.264 +fate-h264-conformance-nl1_sony_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NL1_Sony_D.jsv +fate-h264-conformance-nl2_sony_h: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NL2_Sony_H.jsv +fate-h264-conformance-nl3_sva_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NL3_SVA_E.264 +fate-h264-conformance-nlmq1_jvc_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NLMQ1_JVC_C.264 +fate-h264-conformance-nlmq2_jvc_c: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NLMQ2_JVC_C.264 +fate-h264-conformance-nrf_mw_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/NRF_MW_E.264 fate-h264-conformance-sharp_mp_field_1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/Sharp_MP_Field_1_B.jvt fate-h264-conformance-sharp_mp_field_2_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/Sharp_MP_Field_2_B.jvt fate-h264-conformance-sharp_mp_field_3_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/Sharp_MP_Field_3_B.jvt fate-h264-conformance-sharp_mp_paff_1r2: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/Sharp_MP_PAFF_1r2.jvt fate-h264-conformance-sharp_mp_paff_2r: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/Sharp_MP_PAFF_2.jvt fate-h264-conformance-sl1_sva_b: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/SL1_SVA_B.264 -fate-h264-conformance-sva_ba1_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_BA1_B.264 -fate-h264-conformance-sva_ba2_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_BA2_D.264 -fate-h264-conformance-sva_base_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_Base_B.264 -fate-h264-conformance-sva_cl1_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_CL1_E.264 -fate-h264-conformance-sva_fm1_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_FM1_E.264 -fate-h264-conformance-sva_nl1_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_NL1_B.264 -fate-h264-conformance-sva_nl2_e: CMD = framecrc -i $(SAMPLES)/h264-conformance/SVA_NL2_E.264 +fate-h264-conformance-sva_ba1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_BA1_B.264 +fate-h264-conformance-sva_ba2_d: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_BA2_D.264 +fate-h264-conformance-sva_base_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_Base_B.264 +fate-h264-conformance-sva_cl1_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_CL1_E.264 +fate-h264-conformance-sva_fm1_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_FM1_E.264 +fate-h264-conformance-sva_nl1_b: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL1_B.264 +fate-h264-conformance-sva_nl2_e: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264-conformance/SVA_NL2_E.264 -fate-h264-interlace-crop: CMD = framecrc -vframes 3 -i $(SAMPLES)/h264/interlaced_crop.mp4 -fate-h264-lossless: CMD = framecrc -i $(SAMPLES)/h264/lossless.h264 +fate-h264-interlace-crop: CMD = framecrc -vsync 0 -vframes 3 -i $(SAMPLES)/h264/interlaced_crop.mp4 +fate-h264-lossless: CMD = framecrc -vsync 0 -i $(SAMPLES)/h264/lossless.h264 fate-h264-extreme-plane-pred: CMD = framemd5 -strict 1 -vsync 0 -i $(SAMPLES)/h264/extreme-plane-pred.h264 diff --git a/tests/ref/vsynth1/error b/tests/ref/vsynth1/error index c3543f9d36..7edef21c90 100644 --- a/tests/ref/vsynth1/error +++ b/tests/ref/vsynth1/error @@ -1,4 +1,4 @@ 7416dfd319f04044d4575dc9d1b406e1 *./tests/data/vsynth1/error-mpeg4-adv.avi -756836 ./tests/data/vsynth1/error-mpeg4-adv.avi -ef8bfcd6e0883daba95d0f32486ebe2d *./tests/data/error.vsynth1.out.yuv -stddev: 18.05 PSNR: 23.00 MAXDIFF: 245 bytes: 7603200/ 7603200 + 756836 ./tests/data/vsynth1/error-mpeg4-adv.avi +54342963593ba08bcde95244a011efe5 *./tests/data/error.vsynth1.out.yuv +stddev: 17.59 PSNR: 23.22 MAXDIFF: 240 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth2/error b/tests/ref/vsynth2/error index 4181b2d299..99363f5a42 100644 --- a/tests/ref/vsynth2/error +++ b/tests/ref/vsynth2/error @@ -1,4 +1,4 @@ 90e65096aa9ebafa3fe3f44a5a47cdc4 *./tests/data/vsynth2/error-mpeg4-adv.avi -176588 ./tests/data/vsynth2/error-mpeg4-adv.avi -9fe1082179f80179439953c7397a46ef *./tests/data/error.vsynth2.out.yuv -stddev: 9.00 PSNR: 29.04 MAXDIFF: 168 bytes: 7603200/ 7603200 + 176588 ./tests/data/vsynth2/error-mpeg4-adv.avi +ce12aa852126f2740838dd2da9e21a03 *./tests/data/error.vsynth2.out.yuv +stddev: 10.06 PSNR: 28.08 MAXDIFF: 193 bytes: 7603200/ 7603200 diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh index 933aa648d6..4cf2e20fd8 100755 --- a/tests/regression-funcs.sh +++ b/tests/regression-funcs.sh @@ -102,7 +102,7 @@ do_ffmpeg_crc() do_video_decoding() { - do_ffmpeg $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS $2 + do_ffmpeg $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS -vsync 0 $2 } do_video_encoding() -- cgit v1.2.3 From 808d8ff6bb92e641cdd99a0b06767eabd707b925 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 2 Jun 2011 11:25:56 -0700 Subject: swscale: allocate larger buffer to handle altivec overreads. Altivec sws code intentionally overreads buffers for better performance, so we need to allocate larger buffers to handle that. --- libswscale/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index a2a6a1e191..827abc66d2 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -749,7 +749,7 @@ int sws_init_context(SwsContext *c, SwsFilter *srcFilter, SwsFilter *dstFilter) int srcH= c->srcH; int dstW= c->dstW; int dstH= c->dstH; - int dst_stride = FFALIGN(dstW * sizeof(int16_t), 16), dst_stride_px = dst_stride >> 1; + int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 16, 16), dst_stride_px = dst_stride >> 1; int flags, cpu_flags; enum PixelFormat srcFormat= c->srcFormat; enum PixelFormat dstFormat= c->dstFormat; -- cgit v1.2.3 From e65ab9d94f1c8d8893e32d90467d9525625d306a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 1 Jun 2011 17:26:27 +0100 Subject: Remove unused variables --- ffmpeg.c | 8 +++----- libavcodec/a64multienc.c | 2 -- libavcodec/aaccoder.c | 9 +++------ libavcodec/celp_filters.c | 3 +-- libavcodec/dca.c | 6 ++---- libavcodec/dirac.c | 4 ++-- libavcodec/ituh263dec.c | 6 +++--- libavcodec/mpeg12.c | 3 +-- libavcodec/mpeg12enc.c | 3 +-- libavcodec/mpeg4videodec.c | 19 +++++++------------ libavcodec/mpegvideo_parser.c | 3 +-- libavcodec/msmpeg4.c | 4 +--- libavcodec/pngdec.c | 13 ++++++------- libavcodec/rv10.c | 4 ++-- libavcodec/s302m.c | 3 +-- libavcodec/shorten.c | 3 +-- libavcodec/sp5xdec.c | 3 --- libavcodec/svq1dec.c | 3 +-- libavcodec/targa.c | 6 +++--- libavcodec/truemotion2.c | 14 -------------- libavcodec/tscc.c | 3 --- libavcodec/vmdav.c | 2 -- libavcodec/zmbvenc.c | 4 ++-- libavfilter/vf_fieldorder.c | 3 +-- libavformat/4xm.c | 4 ++-- libavformat/apetag.c | 4 ++-- libavformat/asfdec.c | 19 ++++++++----------- libavformat/avidec.c | 4 ++-- libavformat/gif.c | 4 ---- libavformat/mmf.c | 6 ++---- libavformat/mov.c | 6 +++--- libavformat/oggdec.c | 5 +---- libavformat/oggparseogm.c | 4 +--- libavformat/rl2.c | 6 ++---- libavformat/rmdec.c | 4 ++-- libavformat/rpl.c | 4 ++-- libavformat/rtpdec_latm.c | 5 ++--- libavformat/sauce.c | 4 ++-- libavformat/smacker.c | 2 -- libavformat/sol.c | 3 +-- libavformat/yuv4mpeg.c | 4 ++-- 41 files changed, 76 insertions(+), 143 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 7721438ad1..15ac03e3ed 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1117,7 +1117,7 @@ static void do_video_out(AVFormatContext *s, int *frame_size) { int nb_frames, i, ret, resample_changed; - AVFrame *final_picture, *formatted_picture, *resampling_dst; + AVFrame *final_picture, *formatted_picture; AVCodecContext *enc, *dec; double sync_ipts; @@ -1162,7 +1162,6 @@ static void do_video_out(AVFormatContext *s, formatted_picture = in_picture; final_picture = formatted_picture; - resampling_dst = &ost->pict_tmp; resample_changed = ost->resample_width != dec->width || ost->resample_height != dec->height || @@ -1198,7 +1197,7 @@ static void do_video_out(AVFormatContext *s, } } sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize, - 0, ost->resample_height, resampling_dst->data, resampling_dst->linesize); + 0, ost->resample_height, final_picture->data, final_picture->linesize); } #endif @@ -3617,7 +3616,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) static void new_data_stream(AVFormatContext *oc, int file_idx) { AVStream *st; - AVOutputStream *ost; AVCodec *codec=NULL; AVCodecContext *data_enc; @@ -3626,7 +3624,7 @@ static void new_data_stream(AVFormatContext *oc, int file_idx) fprintf(stderr, "Could not alloc stream\n"); ffmpeg_exit(1); } - ost = new_output_stream(oc, file_idx); + new_output_stream(oc, file_idx); data_enc = st->codec; output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); if (!data_stream_copy) { diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 8286d7ee3c..532f2a2824 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -252,7 +252,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf, int b_width; int req_size; - int num_frames = c->mc_lifetime; int *charmap = c->mc_charmap; uint8_t *colram = c->mc_colram; @@ -280,7 +279,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf, if (!c->mc_lifetime) return 0; /* no more frames in queue, prepare to flush remaining frames */ if (!c->mc_frame_counter) { - num_frames = c->mc_lifetime; c->mc_lifetime = 0; } /* still frames in queue so limit lifetime to remaining frames */ diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 83d3734089..4d5b98fa63 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -311,7 +311,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce int win, int group_len, const float lambda) { BandCodingPath path[120][12]; - int w, swb, cb, start, start2, size; + int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; const int run_bits = sce->ics.num_windows == 1 ? 5 : 3; @@ -329,7 +329,6 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce path[0][cb].run = 0; } for (swb = 0; swb < max_sfb; swb++) { - start2 = start; size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { for (cb = 0; cb < 12; cb++) { @@ -413,7 +412,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda) { BandCodingPath path[120][12]; - int w, swb, cb, start, start2, size; + int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; const int run_bits = sce->ics.num_windows == 1 ? 5 : 3; @@ -431,7 +430,6 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, path[0][cb].run = 0; } for (swb = 0; swb < max_sfb; swb++) { - start2 = start; size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { for (cb = 0; cb < 12; cb++) { @@ -1006,12 +1004,11 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda) { - int start = 0, i, w, w2, g; + int i, w, w2, g; int minq = 255; memset(sce->sf_idx, 0, sizeof(sce->sf_idx)); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { - start = w*128; for (g = 0; g < sce->ics.num_swb; g++) { for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; diff --git a/libavcodec/celp_filters.c b/libavcodec/celp_filters.c index 32eaff3c75..25a6744b04 100644 --- a/libavcodec/celp_filters.c +++ b/libavcodec/celp_filters.c @@ -109,7 +109,7 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, old_out2 = out[-2]; old_out3 = out[-1]; for (n = 0; n <= buffer_length - 4; n+=4) { - float tmp0,tmp1,tmp2,tmp3; + float tmp0,tmp1,tmp2; float val; out0 = in[0]; @@ -160,7 +160,6 @@ void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, tmp0 = out0; tmp1 = out1; tmp2 = out2; - tmp3 = out3; out3 -= a * tmp2; out2 -= a * tmp1; diff --git a/libavcodec/dca.c b/libavcodec/dca.c index dbadebacff..a9b2c9b0c9 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -1535,8 +1535,6 @@ static void dca_exss_parse_header(DCAContext *s) { int ss_index; int blownup; - int header_size; - int hd_size; int num_audiop = 1; int num_assets = 1; int active_ss_mask[8]; @@ -1549,8 +1547,8 @@ static void dca_exss_parse_header(DCAContext *s) ss_index = get_bits(&s->gb, 2); blownup = get_bits1(&s->gb); - header_size = get_bits(&s->gb, 8 + 4 * blownup) + 1; - hd_size = get_bits_long(&s->gb, 16 + 4 * blownup) + 1; + skip_bits(&s->gb, 8 + 4 * blownup); // header_size + skip_bits(&s->gb, 16 + 4 * blownup); // hd_size s->static_fields = get_bits1(&s->gb); if (s->static_fields) { diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c index 0256f29a53..09da1cbd56 100644 --- a/libavcodec/dirac.c +++ b/libavcodec/dirac.c @@ -245,11 +245,11 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, dirac_source_params *source) { - unsigned version_major, version_minor; + unsigned version_major; unsigned video_format, picture_coding_mode; version_major = svq3_get_ue_golomb(gb); - version_minor = svq3_get_ue_golomb(gb); + svq3_get_ue_golomb(gb); /* version_minor */ avctx->profile = svq3_get_ue_golomb(gb); avctx->level = svq3_get_ue_golomb(gb); video_format = svq3_get_ue_golomb(gb); diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index aebfcee027..0bb92da833 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -152,7 +152,7 @@ int ff_h263_decode_mba(MpegEncContext *s) */ static int h263_decode_gob_header(MpegEncContext *s) { - unsigned int val, gfid, gob_number; + unsigned int val, gob_number; int left; /* Check for GOB Start Code */ @@ -183,12 +183,12 @@ static int h263_decode_gob_header(MpegEncContext *s) s->qscale = get_bits(&s->gb, 5); /* SQUANT */ if(get_bits1(&s->gb)==0) return -1; - gfid = get_bits(&s->gb, 2); /* GFID */ + skip_bits(&s->gb, 2); /* GFID */ }else{ gob_number = get_bits(&s->gb, 5); /* GN */ s->mb_x= 0; s->mb_y= s->gob_index* gob_number; - gfid = get_bits(&s->gb, 2); /* GFID */ + skip_bits(&s->gb, 2); /* GFID */ s->qscale = get_bits(&s->gb, 5); /* GQUANT */ } diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 82c2987b90..0e1536f7ab 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2128,14 +2128,13 @@ static void mpeg_decode_gop(AVCodecContext *avctx, Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; - int drop_frame_flag; int time_code_hours, time_code_minutes; int time_code_seconds, time_code_pictures; int broken_link; init_get_bits(&s->gb, buf, buf_size*8); - drop_frame_flag = get_bits1(&s->gb); + skip_bits1(&s->gb); /* drop_frame_flag */ time_code_hours=get_bits(&s->gb,5); time_code_minutes = get_bits(&s->gb,6); diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 8aa31f7581..eb07ecfc5e 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -761,10 +761,9 @@ void ff_mpeg1_encode_init(MpegEncContext *s) if(mv==0) len= ff_mpeg12_mbMotionVectorTable[0][1]; else{ - int val, bit_size, range, code; + int val, bit_size, code; bit_size = f_code - 1; - range = 1 << bit_size; val=mv; if (val < 0) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 81f09c5a4b..22d7ace789 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -397,14 +397,13 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s) header_extension= get_bits1(&s->gb); } if(header_extension){ - int time_increment; int time_incr=0; while (get_bits1(&s->gb) != 0) time_incr++; check_marker(&s->gb, "before time_increment in video packed header"); - time_increment= get_bits(&s->gb, s->time_increment_bits); + skip_bits(&s->gb, s->time_increment_bits); /* time_increment */ check_marker(&s->gb, "before vop_coding_type in video packed header"); skip_bits(&s->gb, 2); /* vop coding type */ @@ -1801,16 +1800,14 @@ no_cplx_est: if (s->scalability) { GetBitContext bak= *gb; - int ref_layer_id; - int ref_layer_sampling_dir; int h_sampling_factor_n; int h_sampling_factor_m; int v_sampling_factor_n; int v_sampling_factor_m; s->hierachy_type= get_bits1(gb); - ref_layer_id= get_bits(gb, 4); - ref_layer_sampling_dir= get_bits1(gb); + skip_bits(gb, 4); /* ref_layer_id */ + skip_bits1(gb); /* ref_layer_sampling_dir */ h_sampling_factor_n= get_bits(gb, 5); h_sampling_factor_m= get_bits(gb, 5); v_sampling_factor_n= get_bits(gb, 5); @@ -1989,15 +1986,13 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){ if (s->shape != RECT_SHAPE) { if (s->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) { - int width, height, hor_spat_ref, ver_spat_ref; - - width = get_bits(gb, 13); + skip_bits(gb, 13); /* width */ skip_bits1(gb); /* marker */ - height = get_bits(gb, 13); + skip_bits(gb, 13); /* height */ skip_bits1(gb); /* marker */ - hor_spat_ref = get_bits(gb, 13); /* hor_spat_ref */ + skip_bits(gb, 13); /* hor_spat_ref */ skip_bits1(gb); /* marker */ - ver_spat_ref = get_bits(gb, 13); /* ver_spat_ref */ + skip_bits(gb, 13); /* ver_spat_ref */ } skip_bits1(gb); /* change_CR_disable */ diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c index 42c85874f6..9688e18625 100644 --- a/libavcodec/mpegvideo_parser.c +++ b/libavcodec/mpegvideo_parser.c @@ -32,7 +32,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, uint32_t start_code; int frame_rate_index, ext_type, bytes_left; int frame_rate_ext_n, frame_rate_ext_d; - int picture_structure, top_field_first, repeat_first_field, progressive_frame; + int top_field_first, repeat_first_field, progressive_frame; int horiz_size_ext, vert_size_ext, bit_rate_ext; int did_set_size=0; //FIXME replace the crap with get_bits() @@ -91,7 +91,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s, break; case 0x8: /* picture coding extension */ if (bytes_left >= 5) { - picture_structure = buf[2]&3; top_field_first = buf[3] & (1 << 7); repeat_first_field = buf[3] & (1 << 1); progressive_frame = buf[4] & (1 << 7); diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index c575a2f206..c740cfa0bd 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -1528,9 +1528,7 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size) /* the alt_bitstream reader could read over the end so we need to check it */ if(left>=length && leftgb, 5); + skip_bits(&s->gb, 5); /* fps */ s->bit_rate= get_bits(&s->gb, 11)*1024; if(s->msmpeg4_version>=3) s->flipflop_rounding= get_bits1(&s->gb); diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 39dbfdcc6f..7477f6746b 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -397,7 +397,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p; uint8_t *crow_buf_base = NULL; uint32_t tag, length; - int ret, crc; + int ret; FFSWAP(AVFrame *, s->current_picture, s->last_picture); avctx->coded_frame= s->current_picture; @@ -451,7 +451,7 @@ static int decode_frame(AVCodecContext *avctx, s->compression_type = *s->bytestream++; s->filter_type = *s->bytestream++; s->interlace_type = *s->bytestream++; - crc = bytestream_get_be32(&s->bytestream); + s->bytestream += 4; /* crc */ s->state |= PNG_IHDR; av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n", s->width, s->height, s->bit_depth, s->color_type, @@ -547,8 +547,7 @@ static int decode_frame(AVCodecContext *avctx, s->state |= PNG_IDAT; if (png_decode_idat(s, length) < 0) goto fail; - /* skip crc */ - crc = bytestream_get_be32(&s->bytestream); + s->bytestream += 4; /* crc */ break; case MKTAG('P', 'L', 'T', 'E'): { @@ -568,7 +567,7 @@ static int decode_frame(AVCodecContext *avctx, s->palette[i] = (0xff << 24); } s->state |= PNG_PLTE; - crc = bytestream_get_be32(&s->bytestream); + s->bytestream += 4; /* crc */ } break; case MKTAG('t', 'R', 'N', 'S'): @@ -584,13 +583,13 @@ static int decode_frame(AVCodecContext *avctx, v = *s->bytestream++; s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24); } - crc = bytestream_get_be32(&s->bytestream); + s->bytestream += 4; /* crc */ } break; case MKTAG('I', 'E', 'N', 'D'): if (!(s->state & PNG_ALLIMAGE)) goto fail; - crc = bytestream_get_be32(&s->bytestream); + s->bytestream += 4; /* crc */ goto exit_loop; default: /* skip tag */ diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index d85cf37cac..6227dc6f6c 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -235,7 +235,7 @@ int rv_decode_dc(MpegEncContext *s, int n) /* read RV 1.0 compatible frame header */ static int rv10_decode_picture_header(MpegEncContext *s) { - int mb_count, pb_frame, marker, unk, mb_xy; + int mb_count, pb_frame, marker, mb_xy; marker = get_bits1(&s->gb); @@ -282,7 +282,7 @@ static int rv10_decode_picture_header(MpegEncContext *s) s->mb_y = 0; mb_count = s->mb_width * s->mb_height; } - unk= get_bits(&s->gb, 3); /* ignored */ + skip_bits(&s->gb, 3); /* ignored */ s->f_code = 1; s->unrestricted_mv = 1; diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index fb1fd867d0..9d623efa8f 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -29,7 +29,7 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { uint32_t h; - int frame_size, channels, id, bits; + int frame_size, channels, bits; if (buf_size <= AES3_HEADER_LEN) { av_log(avctx, AV_LOG_ERROR, "frame is too short\n"); @@ -48,7 +48,6 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf, h = AV_RB32(buf); frame_size = (h >> 16) & 0xffff; channels = ((h >> 14) & 0x0003) * 2 + 2; - id = (h >> 6) & 0x00ff; bits = ((h >> 4) & 0x0003) * 4 + 16; if (AES3_HEADER_LEN + frame_size != buf_size || bits > 24) { diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index f19f0fe348..86e981f417 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -196,7 +196,6 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header { GetBitContext hb; int len; - int chunk_size; short wave_format; init_get_bits(&hb, header, header_size*8); @@ -205,7 +204,7 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header return -1; } - chunk_size = get_le32(&hb); + skip_bits_long(&hb, 32); /* chunk_size */ if (get_le32(&hb) != MKTAG('W','A','V','E')) { av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n"); diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 3d01020a6d..6726c18ca9 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -38,15 +38,12 @@ static int sp5x_decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; AVPacket avpkt_recoded; const int qscale = 5; - const uint8_t *buf_ptr; uint8_t *recoded; int i = 0, j = 0; if (!avctx->width || !avctx->height) return -1; - buf_ptr = buf; - recoded = av_mallocz(buf_size + 1024); if (!recoded) return -1; diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index 0ab09298fc..ef3b4be16c 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -554,9 +554,8 @@ static void svq1_parse_string (GetBitContext *bitbuf, uint8_t *out) { static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) { int frame_size_code; - int temporal_reference; - temporal_reference = get_bits (bitbuf, 8); + skip_bits(bitbuf, 8); /* temporal_reference */ /* frame type */ s->pict_type= get_bits (bitbuf, 2)+1; diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 910cc1ba94..6a852a8528 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -108,18 +108,18 @@ static int decode_frame(AVCodecContext *avctx, AVFrame * const p= (AVFrame*)&s->picture; uint8_t *dst; int stride; - int idlen, pal, compr, x, y, w, h, bpp, flags; + int idlen, compr, y, w, h, bpp, flags; int first_clr, colors, csize; /* parse image header */ CHECK_BUFFER_SIZE(buf, buf_end, 18, "header"); idlen = *buf++; - pal = *buf++; + buf++; /* pal */ compr = *buf++; first_clr = AV_RL16(buf); buf += 2; colors = AV_RL16(buf); buf += 2; csize = *buf++; - x = AV_RL16(buf); buf += 2; + buf += 2; /* x */ y = AV_RL16(buf); buf += 2; w = AV_RL16(buf); buf += 2; h = AV_RL16(buf); buf += 2; diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index f9e607c4f7..23abade214 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -201,7 +201,6 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf) { uint32_t magic; const uint8_t *obuf; - int length; obuf = buf; @@ -212,19 +211,6 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf) /* av_log (ctx->avctx, AV_LOG_ERROR, "TM2 old header: not implemented (yet)\n"); */ return 40; } else if(magic == 0x00000101) { /* new header */ - int w, h, size, flags, xr, yr; - - length = AV_RL32(buf); - buf += 4; - - init_get_bits(&ctx->gb, buf, 32 * 8); - size = get_bits_long(&ctx->gb, 31); - h = get_bits(&ctx->gb, 15); - w = get_bits(&ctx->gb, 15); - flags = get_bits_long(&ctx->gb, 31); - yr = get_bits(&ctx->gb, 9); - xr = get_bits(&ctx->gb, 9); - return 40; } else { av_log (ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic); diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index bd05f02a61..772906aba6 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -75,7 +75,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac int buf_size = avpkt->size; CamtasiaContext * const c = avctx->priv_data; const unsigned char *encoded = buf; - unsigned char *outptr; int zret; // Zlib return code int len = buf_size; @@ -89,8 +88,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac return -1; } - outptr = c->pic.data[0]; // Output image pointer - zret = inflateReset(&(c->zstream)); if (zret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 710c2028cf..d258252d95 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -199,7 +199,6 @@ static void vmd_decode(VmdVideoContext *s) int frame_x, frame_y; int frame_width, frame_height; - int dp_size; frame_x = AV_RL16(&s->buf[6]); frame_y = AV_RL16(&s->buf[8]); @@ -247,7 +246,6 @@ static void vmd_decode(VmdVideoContext *s) } dp = &s->frame.data[0][frame_y * s->frame.linesize[0] + frame_x]; - dp_size = s->frame.linesize[0] * s->avctx->height; pp = &s->prev_frame.data[0][frame_y * s->prev_frame.linesize[0] + frame_x]; switch (meth) { case 1: diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index 271ab2dc96..e4f4860ea0 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -181,7 +181,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void int x, y, bh2, bw2, xored; uint8_t *tsrc, *tprev; uint8_t *mv; - int mx, my, bv; + int mx, my; bw = (avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK; bh = (avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK; @@ -197,7 +197,7 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void tsrc = src + x; tprev = prev + x; - bv = zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored); + zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored); mv[0] = (mx << 1) | !!xored; mv[1] = my << 1; tprev += mx + my * c->pstride; diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c index b55640bbc2..444dffb52c 100644 --- a/libavfilter/vf_fieldorder.c +++ b/libavfilter/vf_fieldorder.c @@ -153,7 +153,7 @@ static void end_frame(AVFilterLink *inlink) AVFilterBufferRef *inpicref = inlink->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; - int h, w, plane, line_step, line_size, line; + int h, plane, line_step, line_size, line; uint8_t *cpy_src, *cpy_dst; if ( inpicref->video->interlaced @@ -162,7 +162,6 @@ static void end_frame(AVFilterLink *inlink) "picture will move %s one line\n", fieldorder->dst_tff ? "up" : "down"); h = inpicref->video->h; - w = inpicref->video->w; for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) { line_step = inpicref->linesize[plane]; line_size = fieldorder->line_size[plane]; diff --git a/libavformat/4xm.c b/libavformat/4xm.c index ff0baaec8f..93c90e8cbc 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -246,7 +246,7 @@ static int fourxm_read_packet(AVFormatContext *s, FourxmDemuxContext *fourxm = s->priv_data; AVIOContext *pb = s->pb; unsigned int fourcc_tag; - unsigned int size, out_size; + unsigned int size; int ret = 0; unsigned int track_number; int packet_read = 0; @@ -295,7 +295,7 @@ static int fourxm_read_packet(AVFormatContext *s, case snd__TAG: track_number = avio_rl32(pb); - out_size= avio_rl32(pb); + avio_skip(pb, 4); size-=8; if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) { diff --git a/libavformat/apetag.c b/libavformat/apetag.c index b8a460a599..6e925354af 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -35,11 +35,11 @@ static int ape_tag_read_field(AVFormatContext *s) { AVIOContext *pb = s->pb; uint8_t key[1024], *value; - uint32_t size, flags; + uint32_t size; int i, c; size = avio_rl32(pb); /* field size */ - flags = avio_rl32(pb); /* field flags */ + avio_skip(pb, 4); /* field flags */ for (i = 0; i < sizeof(key) - 1; i++) { c = avio_r8(pb); if (c < 0x20 || c > 0x7E) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 30642a61fa..789df1274d 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -216,7 +216,6 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) ff_asf_guid g; enum AVMediaType type; int type_specific_size, sizeX; - uint64_t total_size; unsigned int tag1; int64_t pos1, pos2, start_time; int test_for_ext_stream_audio, is_dvr_ms_audio=0; @@ -264,7 +263,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) return -1; } ff_get_guid(pb, &g); - total_size = avio_rl64(pb); + avio_skip(pb, 8); /* total_size */ type_specific_size = avio_rl32(pb); avio_rl32(pb); st->id = avio_rl16(pb) & 0x7f; /* stream id */ @@ -401,7 +400,7 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) AVIOContext *pb = s->pb; ff_asf_guid g; int ext_len, payload_ext_ct, stream_ct, i; - uint32_t ext_d, leak_rate, stream_num; + uint32_t leak_rate, stream_num; unsigned int stream_languageid_index; avio_rl64(pb); // starttime @@ -435,7 +434,7 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size) for (i=0; ipb; ASFContext *asf = s->priv_data; - int n, stream_num, name_len, value_len, value_type, value_num; + int n, stream_num, name_len, value_len, value_num; int ret, i; n = avio_rl16(pb); @@ -529,7 +528,7 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size) avio_rl16(pb); //lang_list_index stream_num= avio_rl16(pb); name_len= avio_rl16(pb); - value_type= avio_rl16(pb); + avio_skip(pb, 2); /* value_type */ value_len= avio_rl32(pb); if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len) @@ -634,10 +633,8 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) // if so the next iteration will pick it up continue; } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) { - int v1, v2; ff_get_guid(pb, &g); - v1 = avio_rl32(pb); - v2 = avio_rl16(pb); + avio_skip(pb, 6); continue; } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) { asf_read_marker(s, gsize); @@ -807,7 +804,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ ASFContext *asf = s->priv_data; int rsize = 1; int num = avio_r8(pb); - int64_t ts0, ts1; + int64_t ts0; asf->packet_segments--; asf->packet_key_frame = num >> 7; @@ -830,7 +827,7 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ // av_log(s, AV_LOG_DEBUG, "\n"); avio_skip(pb, 10); ts0= avio_rl64(pb); - ts1= avio_rl64(pb); + avio_skip(pb, 8);; avio_skip(pb, 12); avio_rl32(pb); avio_skip(pb, asf->packet_replic_size - 8 - 38 - 4); diff --git a/libavformat/avidec.c b/libavformat/avidec.c index a9ff688a86..ff270edae5 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -337,7 +337,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; unsigned int tag, tag1, handler; - int codec_type, stream_index, frame_period, bit_rate; + int codec_type, stream_index, frame_period; unsigned int size; int i; AVStream *st; @@ -407,7 +407,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) /* AVI header */ /* using frame_period is bad idea */ frame_period = avio_rl32(pb); - bit_rate = avio_rl32(pb) * 8; + avio_skip(pb, 4); avio_rl32(pb); avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX; diff --git a/libavformat/gif.c b/libavformat/gif.c index dfd2ec16e8..55deb4d207 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -295,9 +295,7 @@ static int gif_write_video(AVFormatContext *s, AVCodecContext *enc, const uint8_t *buf, int size) { AVIOContext *pb = s->pb; - GIFContext *gif = s->priv_data; int jiffies; - int64_t delay; /* graphic control extension block */ avio_w8(pb, 0x21); @@ -307,8 +305,6 @@ static int gif_write_video(AVFormatContext *s, /* 1 jiffy is 1/70 s */ /* the delay_time field indicates the number of jiffies - 1 */ - delay = gif->file_time - gif->time; - /* XXX: should use delay, in order to be more accurate */ /* instead of using the same rounded value each time */ /* XXX: don't even remember if I really use it for now */ diff --git a/libavformat/mmf.c b/libavformat/mmf.c index ec99c2d0dd..3848d5cf56 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -186,13 +186,13 @@ static int mmf_read_header(AVFormatContext *s, unsigned int tag; AVIOContext *pb = s->pb; AVStream *st; - int64_t file_size, size; + int64_t size; int rate, params; tag = avio_rl32(pb); if (tag != MKTAG('M', 'M', 'M', 'D')) return -1; - file_size = avio_rb32(pb); + avio_skip(pb, 4); /* file_size */ /* Skip some unused chunks that may or may not be present */ for(;; avio_skip(pb, size)) { @@ -263,12 +263,10 @@ static int mmf_read_packet(AVFormatContext *s, AVPacket *pkt) { MMFContext *mmf = s->priv_data; - AVStream *st; int ret, size; if (s->pb->eof_reached) return AVERROR(EIO); - st = s->streams[0]; size = MAX_SIZE; if(size > mmf->data_size) diff --git a/libavformat/mov.c b/libavformat/mov.c index cede1f751a..8ec0d19ed2 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -464,21 +464,21 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom) int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom) { AVStream *st; - int tag, len; + int tag; if (fc->nb_streams < 1) return 0; st = fc->streams[fc->nb_streams-1]; avio_rb32(pb); /* version + flags */ - len = ff_mp4_read_descr(fc, pb, &tag); + ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4ESDescrTag) { avio_rb16(pb); /* ID */ avio_r8(pb); /* priority */ } else avio_rb16(pb); /* ID */ - len = ff_mp4_read_descr(fc, pb, &tag); + ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecConfigDescrTag) ff_mp4_read_dec_config_descr(fc, st, pb); return 0; diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 67678059a1..9562ea9ec0 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -196,8 +196,6 @@ static int ogg_read_page(AVFormatContext *s, int *str) int flags, nsegs; uint64_t gp; uint32_t serial; - uint32_t seq; - uint32_t crc; int size, idx; uint8_t sync[4]; int sp = 0; @@ -230,8 +228,7 @@ static int ogg_read_page(AVFormatContext *s, int *str) flags = avio_r8(bc); gp = avio_rl64 (bc); serial = avio_rl32 (bc); - seq = avio_rl32 (bc); - crc = avio_rl32 (bc); + avio_skip(bc, 8); /* seq, crc */ nsegs = avio_r8(bc); idx = ogg_find_stream (ogg, serial); diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c index dda5be601a..9526c3acc1 100644 --- a/libavformat/oggparseogm.c +++ b/libavformat/oggparseogm.c @@ -39,7 +39,6 @@ ogm_header(AVFormatContext *s, int idx) const uint8_t *p = os->buf + os->pstart; uint64_t time_unit; uint64_t spu; - uint32_t default_len; if(!(*p & 1)) return 0; @@ -74,8 +73,7 @@ ogm_header(AVFormatContext *s, int idx) time_unit = bytestream_get_le64(&p); spu = bytestream_get_le64(&p); - default_len = bytestream_get_le32(&p); - + p += 4; /* default_len */ p += 8; /* buffersize + bits_per_sample */ if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO){ diff --git a/libavformat/rl2.c b/libavformat/rl2.c index f2d68384b8..b4172c284a 100644 --- a/libavformat/rl2.c +++ b/libavformat/rl2.c @@ -80,8 +80,6 @@ static av_cold int rl2_read_header(AVFormatContext *s, unsigned int audio_frame_counter = 0; unsigned int video_frame_counter = 0; unsigned int back_size; - int data_size; - unsigned short encoding_method; unsigned short sound_rate; unsigned short rate; unsigned short channels; @@ -98,14 +96,14 @@ static av_cold int rl2_read_header(AVFormatContext *s, avio_skip(pb,4); /* skip FORM tag */ back_size = avio_rl32(pb); /**< get size of the background frame */ signature = avio_rb32(pb); - data_size = avio_rb32(pb); + avio_skip(pb, 4); /* data size */ frame_count = avio_rl32(pb); /* disallow back_sizes and frame_counts that may lead to overflows later */ if(back_size > INT_MAX/2 || frame_count > INT_MAX / sizeof(uint32_t)) return AVERROR_INVALIDDATA; - encoding_method = avio_rl16(pb); + avio_skip(pb, 2); /* encoding mentod */ sound_rate = avio_rl16(pb); rate = avio_rl16(pb); channels = avio_rl16(pb); diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index 843706dec3..d6a5251c05 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -280,7 +280,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, if (rm_read_audio_stream_info(s, pb, st, rst, 0)) return -1; } else { - int fps, fps2; + int fps; if (avio_rl32(pb) != MKTAG('V', 'I', 'D', 'O')) { fail1: av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); @@ -298,7 +298,7 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVIOContext *pb, fps= avio_rb16(pb); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; avio_rb32(pb); - fps2= avio_rb16(pb); + avio_skip(pb, 2); avio_rb16(pb); if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (avio_tell(pb) - codec_pos))) < 0) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 1ca4a86d1b..935b81d7d8 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -299,9 +299,9 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) stream->codec->codec_tag == 124) { // We have to split Escape 124 frames because there are // multiple frames per chunk in Escape 124 samples. - uint32_t frame_size, frame_flags; + uint32_t frame_size; - frame_flags = avio_rl32(pb); + avio_skip(pb, 4); /* flags */ frame_size = avio_rl32(pb); if (avio_seek(pb, -8, SEEK_CUR) < 0) return AVERROR(EIO); diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index bde34b7ab9..42317a9529 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -108,8 +108,7 @@ static int parse_fmtp_config(AVStream *st, char *value) int len = ff_hex_to_data(NULL, value), i, ret = 0; GetBitContext gb; uint8_t *config; - int audio_mux_version, same_time_framing, num_sub_frames, - num_programs, num_layers; + int audio_mux_version, same_time_framing, num_programs, num_layers; /* Pad this buffer, too, to avoid out of bounds reads with get_bits below */ config = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); @@ -119,7 +118,7 @@ static int parse_fmtp_config(AVStream *st, char *value) init_get_bits(&gb, config, len*8); audio_mux_version = get_bits(&gb, 1); same_time_framing = get_bits(&gb, 1); - num_sub_frames = get_bits(&gb, 6); + skip_bits(&gb, 6); /* num_sub_frames */ num_programs = get_bits(&gb, 4); num_layers = get_bits(&gb, 3); if (audio_mux_version != 0 || same_time_framing != 1 || num_programs != 0 || diff --git a/libavformat/sauce.c b/libavformat/sauce.c index cf33ab7be7..f9ca17ac30 100644 --- a/libavformat/sauce.c +++ b/libavformat/sauce.c @@ -32,7 +32,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g { AVIOContext *pb = avctx->pb; char buf[36]; - int datatype, filetype, t1, t2, nb_comments, flags; + int datatype, filetype, t1, t2, nb_comments; uint64_t start_pos = avio_size(pb) - 128; avio_seek(pb, start_pos, SEEK_SET); @@ -57,7 +57,7 @@ int ff_sauce_read(AVFormatContext *avctx, uint64_t *fsize, int *got_width, int g t1 = avio_rl16(pb); t2 = avio_rl16(pb); nb_comments = avio_r8(pb); - flags = avio_r8(pb); + avio_skip(pb, 1); /* flags */ avio_skip(pb, 4); GET_SAUCE_META("encoder", 22); diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 01d1303ae3..db9a02bb6c 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -233,7 +233,6 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) int i; int frame_size = 0; int palchange = 0; - int pos; if (s->pb->eof_reached || smk->cur_frame >= smk->frames) return AVERROR_EOF; @@ -244,7 +243,6 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) frame_size = smk->frm_size[smk->cur_frame] & (~3); flags = smk->frm_flags[smk->cur_frame]; /* handle palette change event */ - pos = avio_tell(s->pb); if(flags & SMACKER_PAL){ int size, sz, t, off, j, pos; uint8_t *pal = smk->pal; diff --git a/libavformat/sol.c b/libavformat/sol.c index 1c9ce69538..1ebb4d2e30 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -85,7 +85,6 @@ static int sol_channels(int magic, int type) static int sol_read_header(AVFormatContext *s, AVFormatParameters *ap) { - int size; unsigned int magic,tag; AVIOContext *pb = s->pb; unsigned int id, channels, rate, type; @@ -99,7 +98,7 @@ static int sol_read_header(AVFormatContext *s, return -1; rate = avio_rl16(pb); type = avio_r8(pb); - size = avio_rl32(pb); + avio_skip(pb, 4); /* size */ if (magic != 0x0B8D) avio_r8(pb); /* newer SOLs contain padding byte */ diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index d712321162..9a6a0c8315 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -94,7 +94,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) AVPicture *picture; int* first_pkt = s->priv_data; int width, height, h_chroma_shift, v_chroma_shift; - int i, m; + int i; char buf2[Y4M_LINE_MAX+1]; char buf1[20]; uint8_t *ptr, *ptr1, *ptr2; @@ -114,7 +114,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) /* construct frame header */ - m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); + snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); avio_write(pb, buf1, strlen(buf1)); width = st->codec->width; -- cgit v1.2.3 From 14086341bfd2f8f5a5dfbb23868bf8cf677862ef Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 1 Jun 2011 17:29:22 +0100 Subject: nutdec: remove unused variable --- libavformat/nutdec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 0a1ed554e3..d8278175a0 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -190,7 +190,6 @@ static int decode_main_header(NUTContext *nut){ uint64_t tmp, end; unsigned int stream_count; int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res, tmp_head_idx; - int64_t tmp_match; end= get_packetheader(nut, bc, 1, MAIN_STARTCODE); end += avio_tell(bc); @@ -218,7 +217,6 @@ static int decode_main_header(NUTContext *nut){ tmp_pts=0; tmp_mul=1; tmp_stream=0; - tmp_match= 1-(1LL<<62); tmp_head_idx= 0; for(i=0; i<256;){ int tmp_flags = ffio_read_varlen(bc); @@ -232,7 +230,7 @@ static int decode_main_header(NUTContext *nut){ else tmp_res = 0; if(tmp_fields>5) count = ffio_read_varlen(bc); else count = tmp_mul - tmp_size; - if(tmp_fields>6) tmp_match = get_s(bc); + if(tmp_fields>6) get_s(bc); if(tmp_fields>7) tmp_head_idx= ffio_read_varlen(bc); while(tmp_fields-- > 8) -- cgit v1.2.3 From 4c1e56ede86b68b5c600bde4ebeea6153c46f7f9 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Wed, 1 Jun 2011 17:30:28 +0100 Subject: oma: check avio_read() return value --- libavformat/oma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/oma.c b/libavformat/oma.c index 6dd56cf702..6fdf75f17c 100644 --- a/libavformat/oma.c +++ b/libavformat/oma.c @@ -80,6 +80,8 @@ static int oma_read_header(AVFormatContext *s, ff_id3v2_read(s, ID3v2_EA3_MAGIC); ret = avio_read(s->pb, buf, EA3_HEADER_SIZE); + if (ret < EA3_HEADER_SIZE) + return -1; if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}),3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) { av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n"); -- cgit v1.2.3 From 3e3db4d93d71d25927c7c68bb92f9cc8f2003396 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 May 2011 21:16:47 +0200 Subject: bktr: add a framerate private option. --- libavdevice/bktr.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index e8ff557b73..8e3b271983 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -54,11 +54,10 @@ typedef struct { int video_fd; int tuner_fd; int width, height; - int frame_rate; - int frame_rate_base; uint64_t per_frame; int standard; char *video_size; /**< String describing video size, set by a private option. */ + char *framerate; /**< Set by a private option. */ } VideoData; @@ -249,8 +248,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) VideoData *s = s1->priv_data; AVStream *st; int width, height; - int frame_rate; - int frame_rate_base; + AVRational fps; int ret = 0; if (ap->time_base.den <= 0) { @@ -262,14 +260,18 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_log(s1, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto out; } + if ((ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + goto out; + } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) width = ap->width; if (ap->height > 0) height = ap->height; + if (ap->time_base.num) + fps = (AVRational){ap->time_base.den, ap->time_base.num}; #endif - frame_rate = ap->time_base.den; - frame_rate_base = ap->time_base.num; st = av_new_stream(s1, 0); if (!st) { @@ -280,17 +282,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->width = width; s->height = height; - s->frame_rate = frame_rate; - s->frame_rate_base = frame_rate_base; - s->per_frame = ((uint64_t)1000000 * s->frame_rate_base) / s->frame_rate; + s->per_frame = ((uint64_t)1000000 * fps.den) / fps.num; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->pix_fmt = PIX_FMT_YUV420P; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = width; st->codec->height = height; - st->codec->time_base.den = frame_rate; - st->codec->time_base.num = frame_rate_base; + st->codec->time_base.den = fps.num; + st->codec->time_base.num = fps.den; #if FF_API_FORMAT_PARAMETERS if (ap->standard) { @@ -314,6 +314,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) out: av_freep(&s->video_size); + av_freep(&s->framerate); return ret; } @@ -346,6 +347,7 @@ static const AVOption options[] = { { "PALM", "", 0, FF_OPT_TYPE_CONST, {.dbl = PALM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, { "NTSCJ", "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSCJ}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; -- cgit v1.2.3 From 1556186a625fc61bcd06a6a009795f3c895459ea Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 May 2011 21:16:47 +0200 Subject: fbdev: add a framerate private option. --- libavdevice/fbdev.c | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index 6b03be4751..58b3ab4572 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -37,7 +37,10 @@ #include #include +#include "libavutil/log.h" #include "libavutil/mem.h" +#include "libavutil/opt.h" +#include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavformat/avformat.h" @@ -74,8 +77,10 @@ static enum PixelFormat get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *var } typedef struct { + AVClass *class; ///< class for private options int frame_size; ///< size in bytes of a grabbed frame - AVRational time_base; ///< time base + AVRational fps; ///< framerate + char *framerate; ///< framerate string set by a private option int64_t time_frame; ///< time for the next frame to output (in 1/1000000 units) int fd; ///< framebuffer device file descriptor @@ -97,16 +102,21 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, enum PixelFormat pix_fmt; int ret, flags = O_RDONLY; + ret = av_parse_video_rate(&fbdev->fps, fbdev->framerate); + av_freep(&fbdev->framerate); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + return ret; + } +#if FF_API_FORMAT_PARAMETERS + if (ap->time_base.num) + fbdev->fps = (AVRational){ap->time_base.den, ap->time_base.num}; +#endif + if (!(st = av_new_stream(avctx, 0))) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */ - if (ap->time_base.den <= 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid time base %d/%d\n", - ap->time_base.num, ap->time_base.den); - return AVERROR(EINVAL); - } - /* NONBLOCK is ignored by the fbdev driver, only set for consistency */ if (avctx->flags & AVFMT_FLAG_NONBLOCK) flags |= O_NONBLOCK; @@ -146,7 +156,6 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, fbdev->bytes_per_pixel = (fbdev->varinfo.bits_per_pixel + 7) >> 3; fbdev->frame_linesize = fbdev->width * fbdev->bytes_per_pixel; fbdev->frame_size = fbdev->frame_linesize * fbdev->heigth; - fbdev->time_base = ap->time_base; fbdev->time_frame = AV_NOPTS_VALUE; fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_READ, MAP_SHARED, fbdev->fd, 0); if (fbdev->data == MAP_FAILED) { @@ -162,13 +171,13 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx, st->codec->pix_fmt = pix_fmt; st->codec->time_base = ap->time_base; st->codec->bit_rate = - fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel / av_q2d(ap->time_base) * 8; + fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->fps) * 8; av_log(avctx, AV_LOG_INFO, - "w:%d h:%d bpp:%d pixfmt:%s tb:%d/%d bit_rate:%d\n", + "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n", fbdev->width, fbdev->heigth, fbdev->varinfo.bits_per_pixel, av_pix_fmt_descriptors[pix_fmt].name, - ap->time_base.num, ap->time_base.den, + fbdev->fps.num, fbdev->fps.den, st->codec->bit_rate); return 0; @@ -202,7 +211,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt) while (nanosleep(&ts, &ts) < 0 && errno == EINTR); } /* compute the time of the next frame */ - fbdev->time_frame += INT64_C(1000000) * av_q2d(fbdev->time_base); + fbdev->time_frame += INT64_C(1000000) / av_q2d(fbdev->fps); if ((ret = av_new_packet(pkt, fbdev->frame_size)) < 0) return ret; @@ -239,6 +248,20 @@ av_cold static int fbdev_read_close(AVFormatContext *avctx) return 0; } +#define OFFSET(x) offsetof(FBDevContext, x) +#define DEC AV_OPT_FLAG_DECODING_PARAM +static const AVOption options[] = { + { "framerate","", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { NULL }, +}; + +static const AVClass fbdev_class = { + .class_name = "fbdev indev", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_fbdev_demuxer = { .name = "fbdev", .long_name = NULL_IF_CONFIG_SMALL("Linux framebuffer"), @@ -247,4 +270,5 @@ AVInputFormat ff_fbdev_demuxer = { .read_packet = fbdev_read_packet, .read_close = fbdev_read_close, .flags = AVFMT_NOFILE, + .priv_class = &fbdev_class, }; -- cgit v1.2.3 From 121ef2e26d6fefb6b48fbc1082d351bd4d538111 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 May 2011 21:16:47 +0200 Subject: libdc1394: add a framerate private option. --- libavdevice/libdc1394.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index f4340f570c..2811e3b97d 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -60,9 +60,10 @@ typedef struct dc1394_data { dc1394video_frame_t *frame; #endif int current_frame; - int fps; + int frame_rate; /**< frames per 1000 seconds (fps * 1000) */ char *video_size; /**< String describing video size, set by a private option. */ char *pixel_format; /**< Set by a private option. */ + char *framerate; /**< Set by a private option. */ AVPacket packet; } dc1394_data; @@ -102,6 +103,7 @@ static const AVOption options[] = { #endif { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "qvga"}, 0, 0, DEC }, { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "uyvy422"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; @@ -122,7 +124,7 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, struct dc1394_frame_rate *fps; enum PixelFormat pix_fmt; int width, height; - int frame_rate = !ap->time_base.num ? 30000 : av_rescale(1000, ap->time_base.den, ap->time_base.num); + AVRational framerate; int ret = 0; if ((pix_fmt = av_get_pix_fmt(dc1394->pixel_format)) == PIX_FMT_NONE) { @@ -135,6 +137,10 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, av_log(c, AV_LOG_ERROR, "Couldn't parse video size.\n"); goto out; } + if ((ret = av_parse_video_rate(&framerate, dc1394->framerate)) < 0) { + av_log(c, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + goto out; + } #if FF_API_FORMAT_PARAMETERS if (ap->width > 0) width = ap->width; @@ -142,19 +148,22 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, height = ap->height; if (ap->pix_fmt) pix_fmt = ap->pix_fmt; + if (ap->time_base.num) + framerate = (AVRational){ap->time_base.den, ap->time_base.num}; #endif + dc1394->frame_rate = av_rescale(1000, framerate.num, framerate.den); for (fmt = dc1394_frame_formats; fmt->width; fmt++) if (fmt->pix_fmt == pix_fmt && fmt->width == width && fmt->height == height) break; for (fps = dc1394_frame_rates; fps->frame_rate; fps++) - if (fps->frame_rate == frame_rate) + if (fps->frame_rate == dc1394->frame_rate) break; if (!fps->frame_rate || !fmt->width) { av_log(c, AV_LOG_ERROR, "Can't find matching camera format for %s, %dx%d@%d:1000fps\n", avcodec_get_pix_fmt_name(pix_fmt), - width, height, frame_rate); + width, height, dc1394->frame_rate); ret = AVERROR(EINVAL); goto out; } @@ -168,8 +177,8 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, av_set_pts_info(vst, 64, 1, 1000); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_RAWVIDEO; - vst->codec->time_base.den = fps->frame_rate; - vst->codec->time_base.num = 1000; + vst->codec->time_base.den = framerate.num; + vst->codec->time_base.num = framerate.den; vst->codec->width = fmt->width; vst->codec->height = fmt->height; vst->codec->pix_fmt = fmt->pix_fmt; @@ -181,7 +190,6 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, dc1394->packet.flags |= AV_PKT_FLAG_KEY; dc1394->current_frame = 0; - dc1394->fps = fps->frame_rate; vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000); *select_fps = fps; @@ -189,6 +197,7 @@ static inline int dc1394_read_common(AVFormatContext *c, AVFormatParameters *ap, out: av_freep(&dc1394->video_size); av_freep(&dc1394->pixel_format); + av_freep(&dc1394->framerate); return ret; } @@ -267,7 +276,7 @@ static int dc1394_v1_read_packet(AVFormatContext *c, AVPacket *pkt) if (res == DC1394_SUCCESS) { dc1394->packet.data = (uint8_t *)(dc1394->camera.capture_buffer); - dc1394->packet.pts = (dc1394->current_frame * 1000000) / dc1394->fps; + dc1394->packet.pts = (dc1394->current_frame * 1000000) / dc1394->frame_rate; res = dc1394->packet.size; } else { av_log(c, AV_LOG_ERROR, "DMA capture failed\n"); @@ -379,7 +388,7 @@ static int dc1394_v2_read_packet(AVFormatContext *c, AVPacket *pkt) res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame); if (res == DC1394_SUCCESS) { dc1394->packet.data = (uint8_t *)(dc1394->frame->image); - dc1394->packet.pts = (dc1394->current_frame * 1000000) / (dc1394->fps); + dc1394->packet.pts = (dc1394->current_frame * 1000000) / (dc1394->frame_rate); res = dc1394->frame->image_bytes; } else { av_log(c, AV_LOG_ERROR, "DMA capture failed\n"); -- cgit v1.2.3 From c21324eeb6f3175ad2304cb77e990f73a1e810b2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 May 2011 21:16:47 +0200 Subject: v4l2: add a framerate private option. --- libavdevice/v4l2.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 80b640078d..d9dce33b9e 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -73,6 +73,7 @@ struct video_data { int channel; char *video_size; /**< String describing video size, set by a private option. */ char *pixel_format; /**< Set by a private option. */ + char *framerate; /**< Set by a private option. */ }; struct buff_data { @@ -453,13 +454,20 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) struct v4l2_standard standard; struct v4l2_streamparm streamparm = { 0 }; struct v4l2_fract *tpf = &streamparm.parm.capture.timeperframe; - int i; + int i, ret; + AVRational fps; streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (s->framerate && (ret = av_parse_video_rate(&fps, s->framerate)) < 0) { + av_log(s1, AV_LOG_ERROR, "Couldn't parse framerate.\n"); + return ret; + } #if FF_API_FORMAT_PARAMETERS if (ap->channel > 0) s->channel = ap->channel; + if (ap->time_base.num) + fps = (AVRational){ap->time_base.den, ap->time_base.num}; #endif /* set tv video input */ @@ -512,34 +520,32 @@ static int v4l2_set_parameters(AVFormatContext *s1, AVFormatParameters *ap) } } - if (ap->time_base.num && ap->time_base.den) { + if (fps.num && fps.den) { av_log(s1, AV_LOG_DEBUG, "Setting time per frame to %d/%d\n", - ap->time_base.num, ap->time_base.den); - tpf->numerator = ap->time_base.num; - tpf->denominator = ap->time_base.den; + fps.den, fps.num); + tpf->numerator = fps.den; + tpf->denominator = fps.num; if (ioctl(s->fd, VIDIOC_S_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl set time per frame(%d/%d) failed\n", - ap->time_base.num, ap->time_base.den); + fps.den, fps.num); return AVERROR(EIO); } - if (ap->time_base.den != tpf->denominator || - ap->time_base.num != tpf->numerator) { + if (fps.num != tpf->denominator || + fps.den != tpf->numerator) { av_log(s1, AV_LOG_INFO, "The driver changed the time per frame from %d/%d to %d/%d\n", - ap->time_base.num, ap->time_base.den, + fps.den, fps.num, tpf->numerator, tpf->denominator); } } else { - /* if timebase value is not set in ap, read the timebase value from the driver */ + /* if timebase value is not set, read the timebase value from the driver */ if (ioctl(s->fd, VIDIOC_G_PARM, &streamparm) != 0) { av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_PARM): %s\n", strerror(errno)); return AVERROR(errno); } } - ap->time_base.num = tpf->numerator; - ap->time_base.den = tpf->denominator; return 0; } @@ -681,6 +687,7 @@ out: av_freep(&s->video_size); av_freep(&s->pixel_format); av_freep(&s->standard); + av_freep(&s->framerate); return res; } @@ -731,6 +738,7 @@ static const AVOption options[] = { { "channel", "", offsetof(struct video_data, channel), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { NULL }, }; -- cgit v1.2.3 From 4078ed26312adb9adc1948556464705011b28e67 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 May 2011 21:16:47 +0200 Subject: vfwcap: add a framerate private option. --- libavdevice/vfwcap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index d307e11184..c021831945 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -45,6 +45,7 @@ struct vfw_ctx { unsigned int curbufsize; unsigned int frame_num; char *video_size; /**< A string describing video size, set by a private option. */ + char *framerate; /**< Set by a private option. */ }; static enum PixelFormat vfw_pixfmt(DWORD biCompression, WORD biBitCount) @@ -236,6 +237,7 @@ static int vfw_read_close(AVFormatContext *s) } av_freep(&ctx->video_size); + av_freep(&ctx->framerate); return 0; } @@ -252,6 +254,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) DWORD biCompression; WORD biBitCount; int ret; + AVRational fps; if (!strcmp(s->filename, "list")) { for (devnum = 0; devnum <= 9; devnum++) { @@ -269,10 +272,10 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) return AVERROR(EIO); } - if(!ap->time_base.den) { - av_log(s, AV_LOG_ERROR, "A time base must be specified.\n"); - return AVERROR(EIO); - } +#if FF_API_FORMAT_PARAMETERS + if (ap->time_base.num) + fps = (AVRational){ap->time_base.den, ap->time_base.num}; +#endif ctx->hwnd = capCreateCaptureWindow(NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0); if(!ctx->hwnd) { @@ -371,7 +374,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) cparms.fYield = 1; // Spawn a background thread cparms.dwRequestMicroSecPerFrame = - (ap->time_base.num*1000000) / ap->time_base.den; + (fps.den*1000000) / fps.num; cparms.fAbortLeftMouse = 0; cparms.fAbortRightMouse = 0; cparms.fCaptureAudio = 0; @@ -383,7 +386,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail_io; codec = st->codec; - codec->time_base = ap->time_base; + codec->time_base = (AVRational){fps.den, fps.num}; codec->codec_type = AVMEDIA_TYPE_VIDEO; codec->width = bi->bmiHeader.biWidth; codec->height = bi->bmiHeader.biHeight; @@ -471,6 +474,7 @@ static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; -- cgit v1.2.3 From fefa67d536346b39973ab70b892d8ef27215b0b3 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 29 May 2011 15:22:45 +0200 Subject: v4l2: remove one forgotten use of AVFormatParameters.pix_fmt. --- libavdevice/v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index d9dce33b9e..0cd4f38389 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -642,7 +642,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) desired_format = device_try_init(s1, pix_fmt, &s->width, &s->height, &codec_id); if (desired_format == 0) { av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for " - "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, ap->pix_fmt); + "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt); close(s->fd); res = AVERROR(EIO); -- cgit v1.2.3 From 551dfdde70f912d0278730b28d480e32a49b1b5e Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Thu, 2 Jun 2011 21:07:53 +0100 Subject: targa: fix big-endian build --- libavcodec/targa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/targa.c b/libavcodec/targa.c index 6a852a8528..e57fd8ba65 100644 --- a/libavcodec/targa.c +++ b/libavcodec/targa.c @@ -210,6 +210,7 @@ static int decode_frame(AVCodecContext *avctx, CHECK_BUFFER_SIZE(buf, buf_end, img_size, "image data"); for(y = 0; y < s->height; y++){ #if HAVE_BIGENDIAN + int x; if((s->bpp + 1) >> 3 == 2){ uint16_t *dst16 = (uint16_t*)dst; for(x = 0; x < s->width; x++) -- cgit v1.2.3 From b751f611065f1fe1d7216971c4b100c928a3b0d5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 20:40:09 +0200 Subject: Remove stray extra arguments from av_dlog() invocations. --- libavformat/mpeg.c | 2 +- libavformat/mpegenc.c | 2 +- libavformat/mpegts.c | 2 +- libavformat/oggdec.c | 10 ++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 0b663ab512..98506612cd 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -569,7 +569,7 @@ static int mpegps_read_packet(AVFormatContext *s, pkt->dts = dts; pkt->pos = dummy_pos; pkt->stream_index = st->index; - av_dlog(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f size=%d\n", + av_dlog(s, "%d: pts=%0.3f dts=%0.3f size=%d\n", pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0, pkt->size); diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 28ca1cbd5b..98169abcf5 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -1075,7 +1075,7 @@ retry: best_dts= pkt_desc->dts; } - av_dlog(ctx, AV_LOG_DEBUG, "bumping scr, scr:%f, dts:%f\n", + av_dlog(ctx, "bumping scr, scr:%f, dts:%f\n", scr / 90000.0, best_dts / 90000.0); if(best_dts == INT64_MAX) return 0; diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 7c0f3818d5..33675f470f 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1555,7 +1555,7 @@ static int mpegts_read_header(AVFormatContext *s, s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; st->codec->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; - av_dlog(ts->stream, AV_LOG_DEBUG, "start=%0.3f pcr=%0.3f incr=%d\n", + av_dlog(ts->stream, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 9562ea9ec0..f1ad630c5e 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -310,7 +310,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, int complete = 0; int segp = 0, psize = 0; - av_dlog(s, AV_LOG_DEBUG, "ogg_packet: curidx=%i\n", ogg->curidx); + av_dlog(s, "ogg_packet: curidx=%i\n", ogg->curidx); do{ idx = ogg->curidx; @@ -322,8 +322,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, os = ogg->streams + idx; - av_dlog(s, AV_LOG_DEBUG, - "ogg_packet: idx=%d pstart=%d psize=%d segp=%d nsegs=%d\n", + av_dlog(s, "ogg_packet: idx=%d pstart=%d psize=%d segp=%d nsegs=%d\n", idx, os->pstart, os->psize, os->segp, os->nsegs); if (!os->codec){ @@ -356,8 +355,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, } }while (!complete); - av_dlog(s, AV_LOG_DEBUG, - "ogg_packet: idx %i, frame size %i, start %i\n", + av_dlog(s, "ogg_packet: idx %i, frame size %i, start %i\n", idx, os->psize, os->pstart); if (os->granule == -1) @@ -438,7 +436,7 @@ static int ogg_get_headers(AVFormatContext *s) return -1; }while (!ogg->headers); - av_dlog(s, AV_LOG_DEBUG, "found headers\n"); + av_dlog(s, "found headers\n"); return 0; } -- cgit v1.2.3 From 752207e36bd9ee0df0183c5ecb0a53a12caea5df Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 22:46:11 +0200 Subject: cook: Remove unused debug functions. --- libavcodec/cook.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 79aee2e5eb..dfba2c553b 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -166,38 +166,6 @@ typedef struct cook { static float pow2tab[127]; static float rootpow2tab[127]; -/* debug functions */ - -#ifdef COOKDEBUG -static void dump_float_table(float* table, int size, int delimiter) { - int i=0; - av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i); - for (i=0 ; i Date: Thu, 2 Jun 2011 22:49:53 +0200 Subject: Replace custom debug output functions by av_dlog(). --- libavcodec/interplayvideo.c | 24 ++---- libavcodec/vorbisdec.c | 194 +++++++++++++++++++++++--------------------- libavcodec/vqavideo.c | 20 ++--- libavformat/ipmovie.c | 104 +++++++++++------------- 4 files changed, 161 insertions(+), 181 deletions(-) diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c index c12b241fcb..3bbb464aff 100644 --- a/libavcodec/interplayvideo.c +++ b/libavcodec/interplayvideo.c @@ -46,14 +46,6 @@ #define PALETTE_COUNT 256 -/* debugging support */ -#define DEBUG_INTERPLAY 0 -#if DEBUG_INTERPLAY -#define debug_interplay(x,...) av_log(NULL, AV_LOG_DEBUG, x, __VA_ARGS__) -#else -static inline void debug_interplay(const char *format, ...) { } -#endif - typedef struct IpvideoContext { AVCodecContext *avctx; @@ -141,7 +133,7 @@ static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s) y = 8 + ((B - 56) / 29); } - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); + av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->second_last_frame, x, y); } @@ -169,7 +161,7 @@ static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s) y = -( 8 + ((B - 56) / 29)); } - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); + av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->current_frame, x, y); } @@ -192,7 +184,7 @@ static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s) x = -8 + BL; y = -8 + BH; - debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); + av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->last_frame, x, y); } @@ -207,7 +199,7 @@ static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s) x = *s->stream_ptr++; y = *s->stream_ptr++; - debug_interplay (" motion bytes = %d, %d\n", x, y); + av_dlog(NULL, " motion bytes = %d, %d\n", x, y); return copy_from(s, &s->last_frame, x, y); } @@ -588,7 +580,7 @@ static int ipvideo_decode_block_opcode_0x6_16(IpvideoContext *s) x = *s->stream_ptr++; y = *s->stream_ptr++; - debug_interplay (" motion bytes = %d, %d\n", x, y); + av_dlog(NULL, " motion bytes = %d, %d\n", x, y); return copy_from(s, &s->second_last_frame, x, y); } @@ -965,7 +957,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s) static int frame = 0; GetBitContext gb; - debug_interplay("------------------ frame %d\n", frame); + av_dlog(NULL, "------------------ frame %d\n", frame); frame++; if (!s->is_16bpp) { @@ -991,8 +983,8 @@ static void ipvideo_decode_opcodes(IpvideoContext *s) for (x = 0; x < s->avctx->width; x += 8) { opcode = get_bits(&gb, 4); - debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", - x, y, opcode, s->stream_ptr); + av_dlog(NULL, " block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", + x, y, opcode, s->stream_ptr); if (!s->is_16bpp) { s->pixel_ptr = s->current_frame.data[0] + x diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index f6ec74f4a1..c758a440ed 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -20,10 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#undef V_DEBUG -//#define V_DEBUG -//#define AV_DEBUG(...) av_log(NULL, AV_LOG_INFO, __VA_ARGS__) - #include #define ALT_BITSTREAM_READER_LE @@ -41,10 +37,6 @@ #define V_MAX_VLCS (1 << 16) #define V_MAX_PARTITIONS (1 << 20) -#ifndef V_DEBUG -#define AV_DEBUG(...) -#endif - #undef NDEBUG #include @@ -245,7 +237,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) vc->codebook_count = get_bits(gb, 8) + 1; - AV_DEBUG(" Codebooks: %d \n", vc->codebook_count); + av_dlog(NULL, " Codebooks: %d \n", vc->codebook_count); vc->codebooks = av_mallocz(vc->codebook_count * sizeof(*vc->codebooks)); tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(*tmp_vlc_bits)); @@ -256,7 +248,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) vorbis_codebook *codebook_setup = &vc->codebooks[cb]; unsigned ordered, t, entries, used_entries = 0; - AV_DEBUG(" %u. Codebook\n", cb); + av_dlog(NULL, " %u. Codebook\n", cb); if (get_bits(gb, 24) != 0x564342) { av_log(vc->avccontext, AV_LOG_ERROR, @@ -281,17 +273,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) ordered = get_bits1(gb); - AV_DEBUG(" codebook_dimensions %d, codebook_entries %u\n", - codebook_setup->dimensions, entries); + av_dlog(NULL, " codebook_dimensions %d, codebook_entries %u\n", + codebook_setup->dimensions, entries); if (!ordered) { unsigned ce, flag; unsigned sparse = get_bits1(gb); - AV_DEBUG(" not ordered \n"); + av_dlog(NULL, " not ordered \n"); if (sparse) { - AV_DEBUG(" sparse \n"); + av_dlog(NULL, " sparse \n"); used_entries = 0; for (ce = 0; ce < entries; ++ce) { @@ -303,7 +295,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) tmp_vlc_bits[ce] = 0; } } else { - AV_DEBUG(" not sparse \n"); + av_dlog(NULL, " not sparse \n"); used_entries = entries; for (ce = 0; ce < entries; ++ce) @@ -313,17 +305,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) unsigned current_entry = 0; unsigned current_length = get_bits(gb, 5) + 1; - AV_DEBUG(" ordered, current length: %u\n", current_length); //FIXME + av_dlog(NULL, " ordered, current length: %u\n", current_length); //FIXME used_entries = entries; for (; current_entry < used_entries && current_length <= 32; ++current_length) { unsigned i, number; - AV_DEBUG(" number bits: %u ", ilog(entries - current_entry)); + av_dlog(NULL, " number bits: %u ", ilog(entries - current_entry)); number = get_bits(gb, ilog(entries - current_entry)); - AV_DEBUG(" number: %u\n", number); + av_dlog(NULL, " number: %u\n", number); for (i = current_entry; i < number+current_entry; ++i) if (i < used_entries) @@ -339,7 +331,8 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) codebook_setup->lookup_type = get_bits(gb, 4); - AV_DEBUG(" lookup type: %d : %s \n", codebook_setup->lookup_type, codebook_setup->lookup_type ? "vq" : "no lookup"); + av_dlog(NULL, " lookup type: %d : %s \n", codebook_setup->lookup_type, + codebook_setup->lookup_type ? "vq" : "no lookup"); // If the codebook is used for (inverse) VQ, calculate codevectors. @@ -352,14 +345,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) unsigned codebook_value_bits = get_bits(gb, 4) + 1; unsigned codebook_sequence_p = get_bits1(gb); - AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values); - AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value); + av_dlog(NULL, " We expect %d numbers for building the codevectors. \n", + codebook_lookup_values); + av_dlog(NULL, " delta %f minmum %f \n", + codebook_delta_value, codebook_minimum_value); for (i = 0; i < codebook_lookup_values; ++i) { codebook_multiplicands[i] = get_bits(gb, codebook_value_bits); - AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value); - AV_DEBUG(" multiplicand %u\n", codebook_multiplicands[i]); + av_dlog(NULL, " multiplicands*delta+minmum : %e \n", + (float)codebook_multiplicands[i] * codebook_delta_value + codebook_minimum_value); + av_dlog(NULL, " multiplicand %u\n", codebook_multiplicands[i]); } // Weed out unused vlcs and build codevector vector @@ -453,8 +449,8 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc) for (i = 0; i < vorbis_time_count; ++i) { unsigned vorbis_tdtransform = get_bits(gb, 16); - AV_DEBUG(" Vorbis time domain transform %u: %u\n", - vorbis_time_count, vorbis_tdtransform); + av_dlog(NULL, " Vorbis time domain transform %u: %u\n", + vorbis_time_count, vorbis_tdtransform); if (vorbis_tdtransform) { av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n"); @@ -485,7 +481,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) floor_setup->floor_type = get_bits(gb, 16); - AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type); + av_dlog(NULL, " %d. floor type %d \n", i, floor_setup->floor_type); if (floor_setup->floor_type == 1) { int maximum_class = -1; @@ -495,29 +491,33 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) floor_setup->data.t1.partitions = get_bits(gb, 5); - AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions); + av_dlog(NULL, " %d.floor: %d partitions \n", + i, floor_setup->data.t1.partitions); for (j = 0; j < floor_setup->data.t1.partitions; ++j) { floor_setup->data.t1.partition_class[j] = get_bits(gb, 4); if (floor_setup->data.t1.partition_class[j] > maximum_class) maximum_class = floor_setup->data.t1.partition_class[j]; - AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]); + av_dlog(NULL, " %d. floor %d partition class %d \n", + i, j, floor_setup->data.t1.partition_class[j]); } - AV_DEBUG(" maximum class %d \n", maximum_class); + av_dlog(NULL, " maximum class %d \n", maximum_class); for (j = 0; j <= maximum_class; ++j) { floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1; floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2); - AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]); + av_dlog(NULL, " %d floor %d class dim: %d subclasses %d \n", i, j, + floor_setup->data.t1.class_dimensions[j], + floor_setup->data.t1.class_subclasses[j]); if (floor_setup->data.t1.class_subclasses[j]) { GET_VALIDATED_INDEX(floor_setup->data.t1.class_masterbook[j], 8, vc->codebook_count) - AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]); + av_dlog(NULL, " masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]); } for (k = 0; k < (1 << floor_setup->data.t1.class_subclasses[j]); ++k) { @@ -526,7 +526,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) VALIDATE_INDEX(bits, vc->codebook_count) floor_setup->data.t1.subclass_books[j][k] = bits; - AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]); + av_dlog(NULL, " book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]); } } @@ -555,8 +555,8 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) { floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits); - AV_DEBUG(" %u. floor1 Y coord. %d\n", floor1_values, - floor_setup->data.t1.list[floor1_values].x); + av_dlog(NULL, " %u. floor1 Y coord. %d\n", floor1_values, + floor_setup->data.t1.list[floor1_values].x); } } @@ -609,24 +609,24 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) return -1; #ifdef V_DEBUG /* debug output parsed headers */ - AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order); - AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate); - AV_DEBUG("floor0 bark map size: %u\n", - floor_setup->data.t0.bark_map_size); - AV_DEBUG("floor0 amplitude bits: %u\n", - floor_setup->data.t0.amplitude_bits); - AV_DEBUG("floor0 amplitude offset: %u\n", - floor_setup->data.t0.amplitude_offset); - AV_DEBUG("floor0 number of books: %u\n", - floor_setup->data.t0.num_books); - AV_DEBUG("floor0 book list pointer: %p\n", - floor_setup->data.t0.book_list); + /* debug output parsed headers */ + av_dlog(NULL, "floor0 order: %u\n", floor_setup->data.t0.order); + av_dlog(NULL, "floor0 rate: %u\n", floor_setup->data.t0.rate); + av_dlog(NULL, "floor0 bark map size: %u\n", + floor_setup->data.t0.bark_map_size); + av_dlog(NULL, "floor0 amplitude bits: %u\n", + floor_setup->data.t0.amplitude_bits); + av_dlog(NULL, "floor0 amplitude offset: %u\n", + floor_setup->data.t0.amplitude_offset); + av_dlog(NULL, "floor0 number of books: %u\n", + floor_setup->data.t0.num_books); + av_dlog(NULL, "floor0 book list pointer: %p\n", + floor_setup->data.t0.book_list); { int idx; for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) { - AV_DEBUG(" Book %d: %u\n", - idx+1, - floor_setup->data.t0.book_list[idx]); + av_dlog(NULL, " Book %d: %u\n", idx + 1, + floor_setup->data.t0.book_list[idx]); } } #endif @@ -648,7 +648,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) vc->residue_count = get_bits(gb, 6)+1; vc->residues = av_mallocz(vc->residue_count * sizeof(*vc->residues)); - AV_DEBUG(" There are %d residues. \n", vc->residue_count); + av_dlog(NULL, " There are %d residues. \n", vc->residue_count); for (i = 0; i < vc->residue_count; ++i) { vorbis_residue *res_setup = &vc->residues[i]; @@ -657,7 +657,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) res_setup->type = get_bits(gb, 16); - AV_DEBUG(" %u. residue type %d\n", i, res_setup->type); + av_dlog(NULL, " %u. residue type %d\n", i, res_setup->type); res_setup->begin = get_bits(gb, 24); res_setup->end = get_bits(gb, 24); @@ -684,8 +684,9 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) if (!res_setup->classifs) return AVERROR(ENOMEM); - AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size, - res_setup->classifications, res_setup->classbook); + av_dlog(NULL, " begin %d end %d part.size %d classif.s %d classbook %d \n", + res_setup->begin, res_setup->end, res_setup->partition_size, + res_setup->classifications, res_setup->classbook); for (j = 0; j < res_setup->classifications; ++j) { high_bits = 0; @@ -694,7 +695,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) high_bits = get_bits(gb, 5); cascade[j] = (high_bits << 3) + low_bits; - AV_DEBUG(" %u class cascade depth: %d\n", j, ilog(cascade[j])); + av_dlog(NULL, " %u class cascade depth: %d\n", j, ilog(cascade[j])); } res_setup->maxpass = 0; @@ -703,8 +704,8 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) if (cascade[j]&(1 << k)) { GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count) - AV_DEBUG(" %u class cascade depth %u book: %d\n", - j, k, res_setup->books[j][k]); + av_dlog(NULL, " %u class cascade depth %u book: %d\n", + j, k, res_setup->books[j][k]); if (k>res_setup->maxpass) res_setup->maxpass = k; @@ -727,7 +728,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) vc->mapping_count = get_bits(gb, 6)+1; vc->mappings = av_mallocz(vc->mapping_count * sizeof(*vc->mappings)); - AV_DEBUG(" There are %d mappings. \n", vc->mapping_count); + av_dlog(NULL, " There are %d mappings. \n", vc->mapping_count); for (i = 0; i < vc->mapping_count; ++i) { vorbis_mapping *mapping_setup = &vc->mappings[i]; @@ -756,8 +757,8 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) mapping_setup->coupling_steps = 0; } - AV_DEBUG(" %u mapping coupling steps: %d\n", - i, mapping_setup->coupling_steps); + av_dlog(NULL, " %u mapping coupling steps: %d\n", + i, mapping_setup->coupling_steps); if (get_bits(gb, 2)) { av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i); @@ -776,10 +777,9 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc) GET_VALIDATED_INDEX(mapping_setup->submap_floor[j], 8, vc->floor_count) GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count) - AV_DEBUG(" %u mapping %u submap : floor %d, residue %d\n", - i, j, - mapping_setup->submap_floor[j], - mapping_setup->submap_residue[j]); + av_dlog(NULL, " %u mapping %u submap : floor %d, residue %d\n", i, j, + mapping_setup->submap_floor[j], + mapping_setup->submap_residue[j]); } } return 0; @@ -816,8 +816,7 @@ static void create_map(vorbis_context *vc, unsigned floor_number) #ifdef V_DEBUG for (idx = 0; idx <= n; ++idx) { - AV_DEBUG("floor0 map: map at pos %d is %d\n", - idx, map[idx]); + av_dlog(NULL, "floor0 map: map at pos %d is %d\n", idx, map[idx]); } #endif } @@ -830,7 +829,7 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) vc->mode_count = get_bits(gb, 6) + 1; vc->modes = av_mallocz(vc->mode_count * sizeof(*vc->modes)); - AV_DEBUG(" There are %d modes.\n", vc->mode_count); + av_dlog(NULL, " There are %d modes.\n", vc->mode_count); for (i = 0; i < vc->mode_count; ++i) { vorbis_mode *mode_setup = &vc->modes[i]; @@ -840,9 +839,9 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) mode_setup->transformtype = get_bits(gb, 16); //FIXME check GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count); - AV_DEBUG(" %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n", - i, mode_setup->blockflag, mode_setup->windowtype, - mode_setup->transformtype, mode_setup->mapping); + av_dlog(NULL, " %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n", + i, mode_setup->blockflag, mode_setup->windowtype, + mode_setup->transformtype, mode_setup->mapping); } return 0; } @@ -950,7 +949,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc) ff_mdct_init(&vc->mdct[0], bl0, 1, -vc->scale_bias); ff_mdct_init(&vc->mdct[1], bl1, 1, -vc->scale_bias); - AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ", + av_dlog(NULL, " vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ", vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]); /* @@ -1058,7 +1057,7 @@ static int vorbis_floor0_decode(vorbis_context *vc, "floor0 dec: booknumber too high!\n"); book_idx = 0; } - AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx); + av_dlog(NULL, "floor0 dec: booknumber: %u\n", book_idx); codebook = vc->codebooks[vf->book_list[book_idx]]; /* Invalid codebook! */ if (!codebook.codevectors) @@ -1067,13 +1066,13 @@ static int vorbis_floor0_decode(vorbis_context *vc, while (lsp_lenorder) { int vec_off; - AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions); - AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth); + av_dlog(NULL, "floor0 dec: book dimension: %d\n", codebook.dimensions); + av_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth); /* read temp vector */ vec_off = get_vlc2(&vc->gb, codebook.vlc.table, codebook.nb_bits, codebook.maxdepth) * codebook.dimensions; - AV_DEBUG("floor0 dec: vector offset: %d\n", vec_off); + av_dlog(NULL, "floor0 dec: vector offset: %d\n", vec_off); /* copy each vector component and add last to it */ for (idx = 0; idx < codebook.dimensions; ++idx) lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last; @@ -1086,7 +1085,7 @@ static int vorbis_floor0_decode(vorbis_context *vc, { int idx; for (idx = 0; idx < lsp_len; ++idx) - AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx]); + av_dlog(NULL, "floor0 dec: coeff at %d is %f\n", idx, lsp[idx]); } #endif @@ -1141,7 +1140,7 @@ static int vorbis_floor0_decode(vorbis_context *vc, return 1; } - AV_DEBUG(" Floor0 decoded\n"); + av_dlog(NULL, " Floor0 decoded\n"); return 0; } @@ -1168,7 +1167,7 @@ static int vorbis_floor1_decode(vorbis_context *vc, floor1_Y[0] = get_bits(gb, ilog(range - 1)); floor1_Y[1] = get_bits(gb, ilog(range - 1)); - AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]); + av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]); offset = 2; for (i = 0; i < vf->partitions; ++i) { @@ -1178,7 +1177,7 @@ static int vorbis_floor1_decode(vorbis_context *vc, csub = (1 << cbits) - 1; cval = 0; - AV_DEBUG("Cbits %u\n", cbits); + av_dlog(NULL, "Cbits %u\n", cbits); if (cbits) // this reads all subclasses for this partition's class cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table, @@ -1187,8 +1186,8 @@ static int vorbis_floor1_decode(vorbis_context *vc, for (j = 0; j < cdim; ++j) { book = vf->subclass_books[class][cval & csub]; - AV_DEBUG("book %d Cbits %u cval %u bits:%d\n", - book, cbits, cval, get_bits_count(gb)); + av_dlog(NULL, "book %d Cbits %u cval %u bits:%d\n", + book, cbits, cval, get_bits_count(gb)); cval = cval >> cbits; if (book > -1) { @@ -1198,7 +1197,8 @@ static int vorbis_floor1_decode(vorbis_context *vc, floor1_Y[offset+j] = 0; } - AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]); + av_dlog(NULL, " floor(%d) = %d \n", + vf->list[offset+j].x, floor1_Y[offset+j]); } offset+=cdim; } @@ -1256,15 +1256,15 @@ static int vorbis_floor1_decode(vorbis_context *vc, floor1_Y_final[i] = predicted; } - AV_DEBUG(" Decoded floor(%d) = %u / val %u\n", - vf->list[i].x, floor1_Y_final[i], val); + av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n", + vf->list[i].x, floor1_Y_final[i], val); } // Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ? ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x); - AV_DEBUG(" Floor decoded\n"); + av_dlog(NULL, " Floor decoded\n"); return 0; } @@ -1295,7 +1295,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, ch_used = ch; } - AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c); + av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c); for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE? uint16_t voffset, partition_count, j_times_ptns_to_read; @@ -1309,7 +1309,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table, vc->codebooks[vr->classbook].nb_bits, 3); - AV_DEBUG("Classword: %u\n", temp); + av_dlog(NULL, "Classword: %u\n", temp); assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[] for (i = 0; i < c_p_c; ++i) { @@ -1354,7 +1354,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, for (l = 0; l < dim; ++l, ++voffs) { vec[voffs]+=codebook.codevectors[coffs+l]; // FPMATH - AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d \n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs); + av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d \n", + pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs); } } } else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) { // most frequent case optimized @@ -1381,7 +1382,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, vec[voffs ] += codebook.codevectors[coffs + l ]; // FPMATH vec[voffs + vlen] += codebook.codevectors[coffs + l + 1]; // FPMATH - AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l); + av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", + pass, voffset / ch + (voffs % ch) * vlen, + vec[voffset / ch + (voffs % ch) * vlen], + codebook.codevectors[coffs + l], coffs, l); } } @@ -1393,7 +1397,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc, for (l = 0; l < dim; ++l, ++voffs) { vec[voffs / ch + (voffs % ch) * vlen] += codebook.codevectors[coffs + l]; // FPMATH FIXME use if and counter instead of / and % - AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l); + av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", + pass, voffset / ch + (voffs % ch) * vlen, + vec[voffset / ch + (voffs % ch) * vlen], + codebook.codevectors[coffs + l], coffs, l); } } } @@ -1481,8 +1488,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) vc->mode_number = mode_number; mapping = &vc->mappings[vc->modes[mode_number].mapping]; - AV_DEBUG(" Mode number: %u , mapping: %d , blocktype %d\n", mode_number, - vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag); + av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number, + vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag); blockflag = vc->modes[mode_number].blockflag; blocksize = vc->blocksize[blockflag]; @@ -1611,7 +1618,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, if (!buf_size) return 0; - AV_DEBUG("packet length %d \n", buf_size); + av_dlog(NULL, "packet length %d \n", buf_size); init_get_bits(gb, buf, buf_size*8); @@ -1628,7 +1635,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, return buf_size ; } - AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len); + av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", + get_bits_count(gb) / 8, get_bits_count(gb) % 8, len); if (vc->audio_channels > 8) { for (i = 0; i < vc->audio_channels; i++) diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index a842ac7d70..caffddbfa4 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -90,14 +90,6 @@ #define CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z') #define VPTZ_TAG MKBETAG('V', 'P', 'T', 'Z') -#define VQA_DEBUG 0 - -#if VQA_DEBUG -#define vqa_debug printf -#else -static inline void vqa_debug(const char *format, ...) { } -#endif - typedef struct VqaContext { AVCodecContext *avctx; @@ -212,7 +204,7 @@ static void decode_format80(const unsigned char *src, int src_size, while (src_index < src_size) { - vqa_debug(" opcode %02X: ", src[src_index]); + av_dlog(NULL, " opcode %02X: ", src[src_index]); /* 0x80 means that frame is finished */ if (src[src_index] == 0x80) @@ -231,7 +223,7 @@ static void decode_format80(const unsigned char *src, int src_size, src_index += 2; src_pos = AV_RL16(&src[src_index]); src_index += 2; - vqa_debug("(1) copy %X bytes from absolute pos %X\n", count, src_pos); + av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; @@ -243,7 +235,7 @@ static void decode_format80(const unsigned char *src, int src_size, count = AV_RL16(&src[src_index]); src_index += 2; color = src[src_index++]; - vqa_debug("(2) set %X bytes to %02X\n", count, color); + av_dlog(NULL, "(2) set %X bytes to %02X\n", count, color); CHECK_COUNT(); memset(&dest[dest_index], color, count); dest_index += count; @@ -253,7 +245,7 @@ static void decode_format80(const unsigned char *src, int src_size, count = (src[src_index++] & 0x3F) + 3; src_pos = AV_RL16(&src[src_index]); src_index += 2; - vqa_debug("(3) copy %X bytes from absolute pos %X\n", count, src_pos); + av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; @@ -262,7 +254,7 @@ static void decode_format80(const unsigned char *src, int src_size, } else if (src[src_index] > 0x80) { count = src[src_index++] & 0x3F; - vqa_debug("(4) copy %X bytes from source to dest\n", count); + av_dlog(NULL, "(4) copy %X bytes from source to dest\n", count); CHECK_COUNT(); memcpy(&dest[dest_index], &src[src_index], count); src_index += count; @@ -273,7 +265,7 @@ static void decode_format80(const unsigned char *src, int src_size, count = ((src[src_index] & 0x70) >> 4) + 3; src_pos = AV_RB16(&src[src_index]) & 0x0FFF; src_index += 2; - vqa_debug("(5) copy %X bytes from relpos %X\n", count, src_pos); + av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos); CHECK_COUNT(); for (i = 0; i < count; i++) dest[dest_index + i] = dest[dest_index - src_pos + i]; diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index e3215d3b79..e8ba0643f6 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -35,17 +35,6 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" -/* debugging support: #define DEBUG_IPMOVIE as non-zero to see extremely - * verbose information about the demux process */ -#define DEBUG_IPMOVIE 0 - -#if DEBUG_IPMOVIE -#undef printf -#define debug_ipmovie printf -#else -static inline void debug_ipmovie(const char *format, ...) { } -#endif - #define CHUNK_PREAMBLE_SIZE 4 #define OPCODE_PREAMBLE_SIZE 4 @@ -150,8 +139,8 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, s->audio_frame_count += (s->audio_chunk_size - 6) / s->audio_channels; - debug_ipmovie("sending audio frame with pts %"PRId64" (%d audio frames)\n", - pkt->pts, s->audio_frame_count); + av_dlog(NULL, "sending audio frame with pts %"PRId64" (%d audio frames)\n", + pkt->pts, s->audio_frame_count); chunk_type = CHUNK_VIDEO; @@ -195,8 +184,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, pkt->stream_index = s->video_stream_index; pkt->pts = s->video_pts; - debug_ipmovie("sending video frame with pts %"PRId64"\n", - pkt->pts); + av_dlog(NULL, "sending video frame with pts %"PRId64"\n", pkt->pts); s->video_pts += s->frame_pts_inc; @@ -244,36 +232,36 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, chunk_size = AV_RL16(&chunk_preamble[0]); chunk_type = AV_RL16(&chunk_preamble[2]); - debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size); + av_dlog(NULL, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size); switch (chunk_type) { case CHUNK_INIT_AUDIO: - debug_ipmovie("initialize audio\n"); + av_dlog(NULL, "initialize audio\n"); break; case CHUNK_AUDIO_ONLY: - debug_ipmovie("audio only\n"); + av_dlog(NULL, "audio only\n"); break; case CHUNK_INIT_VIDEO: - debug_ipmovie("initialize video\n"); + av_dlog(NULL, "initialize video\n"); break; case CHUNK_VIDEO: - debug_ipmovie("video (and audio)\n"); + av_dlog(NULL, "video (and audio)\n"); break; case CHUNK_SHUTDOWN: - debug_ipmovie("shutdown\n"); + av_dlog(NULL, "shutdown\n"); break; case CHUNK_END: - debug_ipmovie("end\n"); + av_dlog(NULL, "end\n"); break; default: - debug_ipmovie("invalid chunk\n"); + av_dlog(NULL, "invalid chunk\n"); chunk_type = CHUNK_BAD; break; @@ -299,29 +287,29 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, chunk_size -= OPCODE_PREAMBLE_SIZE; chunk_size -= opcode_size; if (chunk_size < 0) { - debug_ipmovie("chunk_size countdown just went negative\n"); + av_dlog(NULL, "chunk_size countdown just went negative\n"); chunk_type = CHUNK_BAD; break; } - debug_ipmovie(" opcode type %02X, version %d, 0x%04X bytes: ", - opcode_type, opcode_version, opcode_size); + av_dlog(NULL, " opcode type %02X, version %d, 0x%04X bytes: ", + opcode_type, opcode_version, opcode_size); switch (opcode_type) { case OPCODE_END_OF_STREAM: - debug_ipmovie("end of stream\n"); + av_dlog(NULL, "end of stream\n"); avio_skip(pb, opcode_size); break; case OPCODE_END_OF_CHUNK: - debug_ipmovie("end of chunk\n"); + av_dlog(NULL, "end of chunk\n"); avio_skip(pb, opcode_size); break; case OPCODE_CREATE_TIMER: - debug_ipmovie("create timer\n"); + av_dlog(NULL, "create timer\n"); if ((opcode_version > 0) || (opcode_size > 6)) { - debug_ipmovie("bad create_timer opcode\n"); + av_dlog(NULL, "bad create_timer opcode\n"); chunk_type = CHUNK_BAD; break; } @@ -331,14 +319,15 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; } s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]); - debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n", - 1000000.0/s->frame_pts_inc, AV_RL32(&scratch[0]), AV_RL16(&scratch[4])); + av_dlog(NULL, " %.2f frames/second (timer div = %d, subdiv = %d)\n", + 1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]), + AV_RL16(&scratch[4])); break; case OPCODE_INIT_AUDIO_BUFFERS: - debug_ipmovie("initialize audio buffers\n"); + av_dlog(NULL, "initialize audio buffers\n"); if ((opcode_version > 1) || (opcode_size > 10)) { - debug_ipmovie("bad init_audio_buffers opcode\n"); + av_dlog(NULL, "bad init_audio_buffers opcode\n"); chunk_type = CHUNK_BAD; break; } @@ -360,23 +349,22 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, s->audio_type = CODEC_ID_PCM_S16LE; else s->audio_type = CODEC_ID_PCM_U8; - debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n", - s->audio_bits, - s->audio_sample_rate, - (s->audio_channels == 2) ? "stereo" : "mono", - (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ? - "Interplay audio" : "PCM"); + av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n", + s->audio_bits, s->audio_sample_rate, + (s->audio_channels == 2) ? "stereo" : "mono", + (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ? + "Interplay audio" : "PCM"); break; case OPCODE_START_STOP_AUDIO: - debug_ipmovie("start/stop audio\n"); + av_dlog(NULL, "start/stop audio\n"); avio_skip(pb, opcode_size); break; case OPCODE_INIT_VIDEO_BUFFERS: - debug_ipmovie("initialize video buffers\n"); + av_dlog(NULL, "initialize video buffers\n"); if ((opcode_version > 2) || (opcode_size > 8)) { - debug_ipmovie("bad init_video_buffers opcode\n"); + av_dlog(NULL, "bad init_video_buffers opcode\n"); chunk_type = CHUNK_BAD; break; } @@ -392,8 +380,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, } else { s->video_bpp = 16; } - debug_ipmovie("video resolution: %d x %d\n", - s->video_width, s->video_height); + av_dlog(NULL, "video resolution: %d x %d\n", + s->video_width, s->video_height); break; case OPCODE_UNKNOWN_06: @@ -403,17 +391,17 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, case OPCODE_UNKNOWN_13: case OPCODE_UNKNOWN_14: case OPCODE_UNKNOWN_15: - debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type); + av_dlog(NULL, "unknown (but documented) opcode %02X\n", opcode_type); avio_skip(pb, opcode_size); break; case OPCODE_SEND_BUFFER: - debug_ipmovie("send buffer\n"); + av_dlog(NULL, "send buffer\n"); avio_skip(pb, opcode_size); break; case OPCODE_AUDIO_FRAME: - debug_ipmovie("audio frame\n"); + av_dlog(NULL, "audio frame\n"); /* log position and move on for now */ s->audio_chunk_offset = avio_tell(pb); @@ -422,26 +410,26 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; case OPCODE_SILENCE_FRAME: - debug_ipmovie("silence frame\n"); + av_dlog(NULL, "silence frame\n"); avio_skip(pb, opcode_size); break; case OPCODE_INIT_VIDEO_MODE: - debug_ipmovie("initialize video mode\n"); + av_dlog(NULL, "initialize video mode\n"); avio_skip(pb, opcode_size); break; case OPCODE_CREATE_GRADIENT: - debug_ipmovie("create gradient\n"); + av_dlog(NULL, "create gradient\n"); avio_skip(pb, opcode_size); break; case OPCODE_SET_PALETTE: - debug_ipmovie("set palette\n"); + av_dlog(NULL, "set palette\n"); /* check for the logical maximum palette size * (3 * 256 + 4 bytes) */ if (opcode_size > 0x304) { - debug_ipmovie("demux_ipmovie: set_palette opcode too large\n"); + av_dlog(NULL, "demux_ipmovie: set_palette opcode too large\n"); chunk_type = CHUNK_BAD; break; } @@ -455,7 +443,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, last_color = first_color + AV_RL16(&scratch[2]) - 1; /* sanity check (since they are 16 bit values) */ if ((first_color > 0xFF) || (last_color > 0xFF)) { - debug_ipmovie("demux_ipmovie: set_palette indexes out of range (%d -> %d)\n", + av_dlog(NULL, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n", first_color, last_color); chunk_type = CHUNK_BAD; break; @@ -473,12 +461,12 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; case OPCODE_SET_PALETTE_COMPRESSED: - debug_ipmovie("set palette compressed\n"); + av_dlog(NULL, "set palette compressed\n"); avio_skip(pb, opcode_size); break; case OPCODE_SET_DECODING_MAP: - debug_ipmovie("set decoding map\n"); + av_dlog(NULL, "set decoding map\n"); /* log position and move on for now */ s->decode_map_chunk_offset = avio_tell(pb); @@ -487,7 +475,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; case OPCODE_VIDEO_DATA: - debug_ipmovie("set video data\n"); + av_dlog(NULL, "set video data\n"); /* log position and move on for now */ s->video_chunk_offset = avio_tell(pb); @@ -496,7 +484,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb, break; default: - debug_ipmovie("*** unknown opcode type\n"); + av_dlog(NULL, "*** unknown opcode type\n"); chunk_type = CHUNK_BAD; break; -- cgit v1.2.3 From 2366462429d9cc7ed9715c037f204fcefeff8ea4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 22:55:51 +0200 Subject: Replace #ifdef + av_log() combinations by av_dlog(). --- libavcodec/ivi_common.c | 4 ++-- libavcodec/svq1dec.c | 28 ++++++++++------------------ libavcodec/vorbisdec.c | 13 +++++-------- libavdevice/dv1394.c | 8 ++------ 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index ac4c68e05f..2b684e8b9e 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -418,8 +418,8 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile) break; pos = band->scan[scan_pos]; - if (IVI_DEBUG && !val) - av_log(NULL, AV_LOG_ERROR, "Val = 0 encountered!\n"); + if (!val) + av_dlog(NULL, "Val = 0 encountered!\n"); q = (base_tab[pos] * quant) >> 9; if (q > 1) diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index ef3b4be16c..ef4cde1b7f 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -238,9 +238,9 @@ static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int } if ((stages > 0) && (level >= 4)) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level); -#endif + av_dlog(s->avctx, + "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n", + stages, level); return -1; /* invalid vector */ } @@ -288,9 +288,9 @@ static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, if (stages == -1) continue; /* skip vector */ if ((stages > 0) && (level >= 4)) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level); -#endif + av_dlog(s->avctx, + "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n", + stages, level); return -1; /* invalid vector */ } @@ -499,9 +499,7 @@ static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf, if (result != 0) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_block %i\n",result); -#endif + av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result); break; } result = svq1_decode_block_non_intra (bitbuf, current, pitch); @@ -512,9 +510,7 @@ static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf, if (result != 0) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_4v_block %i\n",result); -#endif + av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result); break; } result = svq1_decode_block_non_intra (bitbuf, current, pitch); @@ -660,9 +656,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, if (result != 0) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_frame_header %i\n",result); -#endif + av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n",result); return result; } @@ -729,9 +723,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, linesize, pmv, x, y); if (result != 0) { -#ifdef DEBUG_SVQ1 - av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); -#endif + av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n",result); goto err; } } diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index c758a440ed..0c1850c814 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -370,9 +370,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) float last = 0.0; unsigned lookup_offset = i; -#ifdef V_DEBUG - av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %u ,", i); -#endif + av_dlog(vc->avccontext, "Lookup offset %u ,", i); for (k = 0; k < dim; ++k) { unsigned multiplicand_offset = lookup_offset % codebook_lookup_values; @@ -383,12 +381,11 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) } tmp_vlc_bits[j] = tmp_vlc_bits[i]; -#ifdef V_DEBUG - av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %u, vector: ", j); + av_dlog(vc->avccontext, "real lookup offset %u, vector: ", j); for (k = 0; k < dim; ++k) - av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j * dim + k]); - av_log(vc->avccontext, AV_LOG_INFO, "\n"); -#endif + av_dlog(vc->avccontext, " %f ", + codebook_setup->codevectors[j * dim + k]); + av_dlog(vc->avccontext, "\n"); ++j; } diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c index c9b7a69d6f..f414eb3388 100644 --- a/libavdevice/dv1394.c +++ b/libavdevice/dv1394.c @@ -177,15 +177,13 @@ restart_poll: av_log(context, AV_LOG_ERROR, "Failed to get status: %s\n", strerror(errno)); return AVERROR(EIO); } -#ifdef DV1394_DEBUG - av_log(context, AV_LOG_DEBUG, "DV1394: status\n" + av_dlog(context, "DV1394: status\n" "\tactive_frame\t%d\n" "\tfirst_clear_frame\t%d\n" "\tn_clear_frames\t%d\n" "\tdropped_frames\t%d\n", s.active_frame, s.first_clear_frame, s.n_clear_frames, s.dropped_frames); -#endif dv->avail = s.n_clear_frames; dv->index = s.first_clear_frame; @@ -200,10 +198,8 @@ restart_poll: } } -#ifdef DV1394_DEBUG - av_log(context, AV_LOG_DEBUG, "index %d, avail %d, done %d\n", dv->index, dv->avail, + av_dlog(context, "index %d, avail %d, done %d\n", dv->index, dv->avail, dv->done); -#endif size = dv_produce_packet(dv->dv_demux, pkt, dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), -- cgit v1.2.3 From 0fc9c6554e85b601b61367574fec333fb5a074e6 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 22:56:29 +0200 Subject: Remove pointless #ifdefs around function declarations in a header. --- libavcodec/ivi_common.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h index 582a1d71fc..0a5e9b1384 100644 --- a/libavcodec/ivi_common.h +++ b/libavcodec/ivi_common.h @@ -340,7 +340,6 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band, */ void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch); -#if IVI_DEBUG /** * Calculate band checksum from band data. */ @@ -350,6 +349,5 @@ uint16_t ivi_calc_band_checksum (IVIBandDesc *band); * Verify that band data lies in range. */ int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch); -#endif #endif /* AVCODEC_IVI_COMMON_H */ -- cgit v1.2.3 From fb52cf8267984f97dcb18aaf5dcbad42dd6fcacd Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 22:59:27 +0200 Subject: cook: Remove non-compiling debug output. random_state was changed from an int to a struct and can no longer be printed as easily as before. --- libavcodec/cook.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index dfba2c553b..e6e2508c84 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1023,7 +1023,6 @@ static void dump_cook_context(COOKContext *q) PRINT("samples_per_channel",q->subpacket[0].samples_per_channel); PRINT("samples_per_frame",q->subpacket[0].samples_per_frame); PRINT("subbands",q->subpacket[0].subbands); - PRINT("random_state",q->random_state); PRINT("js_subband_start",q->subpacket[0].js_subband_start); PRINT("log2_numvector_size",q->subpacket[0].log2_numvector_size); PRINT("numvector_size",q->subpacket[0].numvector_size); -- cgit v1.2.3 From ec6313ad866fc04b7b56af4d639182bf595d3829 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 23:02:34 +0200 Subject: vorbis: Remove pointless DEBUG #ifdef around debug output macros. --- libavcodec/vorbisdec.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 0c1850c814..ac64ae8c32 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -605,7 +605,6 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) if (!floor_setup->data.t0.lsp) return -1; -#ifdef V_DEBUG /* debug output parsed headers */ /* debug output parsed headers */ av_dlog(NULL, "floor0 order: %u\n", floor_setup->data.t0.order); av_dlog(NULL, "floor0 rate: %u\n", floor_setup->data.t0.rate); @@ -626,7 +625,6 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc) floor_setup->data.t0.book_list[idx]); } } -#endif } else { av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n"); return -1; @@ -811,11 +809,9 @@ static void create_map(vorbis_context *vc, unsigned floor_number) vf->map_size[blockflag] = n; } -#ifdef V_DEBUG for (idx = 0; idx <= n; ++idx) { av_dlog(NULL, "floor0 map: map at pos %d is %d\n", idx, map[idx]); } -#endif } static int vorbis_parse_setup_hdr_modes(vorbis_context *vc) @@ -1077,14 +1073,12 @@ static int vorbis_floor0_decode(vorbis_context *vc, lsp_len += codebook.dimensions; } -#ifdef V_DEBUG /* DEBUG: output lsp coeffs */ { int idx; for (idx = 0; idx < lsp_len; ++idx) av_dlog(NULL, "floor0 dec: coeff at %d is %f\n", idx, lsp[idx]); } -#endif /* synthesize floor output vector */ { -- cgit v1.2.3 From 068aa387128850da488af262d54986d03eebe423 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 23:03:54 +0200 Subject: vorbis: Remove non-compiling debug statement. --- libavcodec/vorbisdec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index ac64ae8c32..b969d45783 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -1089,9 +1089,6 @@ static int vorbis_floor0_decode(vorbis_context *vc, for (i = 0; i < order; i++) lsp[i] = 2.0f * cos(lsp[i]); - AV_DEBUG("floor0 synth: map_size = %d; m = %d; wstep = %f\n", - vf->map_size, order, wstep); - i = 0; while (i < vf->map_size[blockflag]) { int j, iter_cond = vf->map[blockflag][i]; -- cgit v1.2.3 From f190f676bc93a7e80344f2feeb3b9b44604d4717 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 2 Jun 2011 22:45:15 +0200 Subject: Replace custom DEBUG preprocessor trickery by the standard one. --- ffserver.c | 4 ++-- libavcodec/cook.c | 5 ++--- libavcodec/indeo5.c | 2 +- libavcodec/ivi_common.c | 2 +- libavcodec/ivi_common.h | 2 -- libavcodec/svq1dec.c | 3 --- libavcodec/vorbis.c | 9 +++------ libavdevice/dv1394.c | 3 --- libavdevice/vfwcap.c | 4 +--- libavformat/ape.c | 4 +--- libavformat/apetag.c | 2 -- libavformat/rtsp.c | 3 --- 12 files changed, 11 insertions(+), 32 deletions(-) diff --git a/ffserver.c b/ffserver.c index 56bcba58f7..30edb05969 100644 --- a/ffserver.c +++ b/ffserver.c @@ -1760,7 +1760,7 @@ static int http_parse_request(HTTPContext *c) } } -#ifdef DEBUG_WMP +#ifdef DEBUG http_log("\nGot request:\n%s\n", c->buffer); #endif @@ -1790,7 +1790,7 @@ static int http_parse_request(HTTPContext *c) return 0; } -#ifdef DEBUG_WMP +#ifdef DEBUG if (strcmp(stream->filename + strlen(stream->filename) - 4, ".asf") == 0) http_log("\nGot request:\n%s\n", c->buffer); #endif diff --git a/libavcodec/cook.c b/libavcodec/cook.c index e6e2508c84..84211a6d08 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -66,7 +66,6 @@ #define SUBBAND_SIZE 20 #define MAX_SUBPACKETS 5 -//#define COOKDEBUG typedef struct { int *now; @@ -1005,7 +1004,7 @@ static int cook_decode_frame(AVCodecContext *avctx, return avctx->block_align; } -#ifdef COOKDEBUG +#ifdef DEBUG static void dump_cook_context(COOKContext *q) { //int i=0; @@ -1247,7 +1246,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) else avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; -#ifdef COOKDEBUG +#ifdef DEBUG dump_cook_context(q); #endif return 0; diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c index 088b45a263..ba1bc18eff 100644 --- a/libavcodec/indeo5.c +++ b/libavcodec/indeo5.c @@ -629,7 +629,7 @@ static int decode_band(IVI5DecContext *ctx, int plane_num, FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]); } -#if IVI_DEBUG +#ifdef DEBUG if (band->checksum_present) { uint16_t chksum = ivi_calc_band_checksum(band); if (chksum != band->checksum) { diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index 2b684e8b9e..bd3d4e6fd4 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -563,7 +563,7 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band, } -#if IVI_DEBUG +#ifdef DEBUG uint16_t ivi_calc_band_checksum (IVIBandDesc *band) { int x, y; diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h index 0a5e9b1384..fd3d82515a 100644 --- a/libavcodec/ivi_common.h +++ b/libavcodec/ivi_common.h @@ -33,8 +33,6 @@ #include "get_bits.h" #include -#define IVI_DEBUG 0 - #define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes /** diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index ef4cde1b7f..fc36bc3489 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -33,7 +33,6 @@ */ -//#define DEBUG_SVQ1 #include "avcodec.h" #include "dsputil.h" #include "mpegvideo.h" @@ -705,9 +704,7 @@ static int svq1_decode_frame(AVCodecContext *avctx, result = svq1_decode_block_intra (&s->gb, ¤t[x], linesize); if (result != 0) { -//#ifdef DEBUG_SVQ1 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); -//#endif goto err; } } diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index 7198abe38d..f413170b6a 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -20,9 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#undef V_DEBUG -//#define V_DEBUG - #define ALT_BITSTREAM_READER_LE #include "avcodec.h" #include "get_bits.h" @@ -57,7 +54,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) unsigned i, j, p, code; -#ifdef V_DEBUG +#ifdef DEBUG GetBitContext gb; #endif @@ -74,7 +71,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) for (i = 0; i < bits[p]; ++i) exit_at_level[i+1] = 1 << i; -#ifdef V_DEBUG +#ifdef DEBUG av_log(NULL, AV_LOG_INFO, " %u. of %u code len %d code %d - ", p, num, bits[p], codes[p]); init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]); for (i = 0; i < bits[p]; ++i) @@ -102,7 +99,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num) exit_at_level[j] = code + (1 << (j - 1)); codes[p] = code; -#ifdef V_DEBUG +#ifdef DEBUG av_log(NULL, AV_LOG_INFO, " %d. code len %d code %d - ", p, bits[p], codes[p]); init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]); for (i = 0; i < bits[p]; ++i) diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c index f414eb3388..565cf4cc4e 100644 --- a/libavdevice/dv1394.c +++ b/libavdevice/dv1394.c @@ -33,9 +33,6 @@ #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavformat/avformat.h" - -#undef DV1394_DEBUG - #include "libavformat/dv.h" #include "dv1394.h" diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index c021831945..5dd873bdcb 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -26,8 +26,6 @@ #include #include -//#define DEBUG_VFW - /* Defines for VFW missing from MinGW. * Remove this when MinGW incorporates them. */ #define HWND_MESSAGE ((HWND)-3) @@ -122,7 +120,7 @@ static void dump_captureparms(AVFormatContext *s, CAPTUREPARMS *cparms) static void dump_videohdr(AVFormatContext *s, VIDEOHDR *vhdr) { -#ifdef DEBUG_VFW +#ifdef DEBUG av_log(s, AV_LOG_DEBUG, "VIDEOHDR\n"); dstruct(s, vhdr, lpData, "p"); dstruct(s, vhdr, dwBufferLength, "lu"); diff --git a/libavformat/ape.c b/libavformat/ape.c index d7c1447b01..90b02619e0 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -26,8 +26,6 @@ #include "avformat.h" #include "apetag.h" -#define ENABLE_DEBUG 0 - /* The earliest and latest file formats supported by this library */ #define APE_MIN_VERSION 3950 #define APE_MAX_VERSION 3990 @@ -96,7 +94,7 @@ static int ape_probe(AVProbeData * p) static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx) { -#if ENABLE_DEBUG +#ifdef DEBUG int i; av_log(s, AV_LOG_DEBUG, "Descriptor Block:\n\n"); diff --git a/libavformat/apetag.c b/libavformat/apetag.c index 6e925354af..2eb1673cc4 100644 --- a/libavformat/apetag.c +++ b/libavformat/apetag.c @@ -24,8 +24,6 @@ #include "avformat.h" #include "apetag.h" -#define ENABLE_DEBUG 0 - #define APE_TAG_VERSION 2000 #define APE_TAG_FOOTER_BYTES 32 #define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 2d1438d3ed..c78b762a36 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -45,7 +45,6 @@ #include "url.h" //#define DEBUG -//#define DEBUG_RTP_TCP /* Timeout values for socket poll, in ms, * and read_packet(), in seconds */ @@ -860,9 +859,7 @@ int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply, q = buf; for (;;) { ret = ffurl_read_complete(rt->rtsp_hd, &ch, 1); -#ifdef DEBUG_RTP_TCP av_dlog(s, "ret=%d c=%02x [%c]\n", ret, ch, ch); -#endif if (ret != 1) return AVERROR_EOF; if (ch == '\n') -- cgit v1.2.3