From e32bea8eb479d39359042cb43fa0cb9f92863e6b Mon Sep 17 00:00:00 2001 From: Christophe Gisquet Date: Wed, 28 Nov 2012 22:47:25 +0100 Subject: [PATCH 1/3] aac: avoid a memcpy in sbr_qmf_analysis Swapping buffer indices allows saving one memcpy that accounts for 1% of the runtime, according to oprofile. Signed-off-by: Luca Barbato --- libavcodec/aacsbr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index df5d9279bf..3fbba6f1dc 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -1153,10 +1153,9 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) */ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, SBRDSPContext *sbrdsp, const float *in, float *x, - float z[320], float W[2][32][32][2]) + float z[320], float W[2][32][32][2], int buf_idx) { int i; - memcpy(W[0], W[1], sizeof(W[0])); memcpy(x , x+1024, (320-32)*sizeof(x[0])); memcpy(x+288, in, 1024*sizeof(x[0])); for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames @@ -1165,7 +1164,7 @@ static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, sbrdsp->sum64x5(z); sbrdsp->qmf_pre_shuffle(z); mdct->imdct_half(mdct, z, z+64); - sbrdsp->qmf_post_shuffle(W[1][i], z); + sbrdsp->qmf_post_shuffle(W[buf_idx][i], z); x += 32; } } @@ -1301,7 +1300,8 @@ static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data) /// Generate the subband filtered lowband static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, - float X_low[32][40][2], const float W[2][32][32][2]) + float X_low[32][40][2], const float W[2][32][32][2], + int buf_idx) { int i, k; const int t_HFGen = 8; @@ -1309,14 +1309,15 @@ static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr, memset(X_low, 0, 32*sizeof(*X_low)); for (k = 0; k < sbr->kx[1]; k++) { for (i = t_HFGen; i < i_f + t_HFGen; i++) { - X_low[k][i][0] = W[1][i - t_HFGen][k][0]; - X_low[k][i][1] = W[1][i - t_HFGen][k][1]; + X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1]; } } + buf_idx = 1-buf_idx; for (k = 0; k < sbr->kx[0]; k++) { for (i = 0; i < t_HFGen; i++) { - X_low[k][i][0] = W[0][i + i_f - t_HFGen][k][0]; - X_low[k][i][1] = W[0][i + i_f - t_HFGen][k][1]; + X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0]; + X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1]; } } return 0; @@ -1665,8 +1666,8 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac, /* decode channel */ sbr_qmf_analysis(&ac->dsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples, (float*)sbr->qmf_filter_scratch, - sbr->data[ch].W); - sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W); + sbr->data[ch].W, sbr->data[ch].Ypos); + sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W, sbr->data[ch].Ypos); sbr->data[ch].Ypos ^= 1; if (sbr->start) { sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]); From 89a4465bd9d12c794434dace4332875e57c61a6b Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Fri, 30 Nov 2012 15:44:19 +0100 Subject: [PATCH 2/3] avprobe: report per stream bit rate if set by the decoder --- avprobe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/avprobe.c b/avprobe.c index 3a3ae0fa7d..4da9621b85 100644 --- a/avprobe.c +++ b/avprobe.c @@ -654,6 +654,10 @@ static void show_stream(AVFormatContext *fmt_ctx, int stream_idx) probe_str("avg_frame_rate", rational_string(val_str, sizeof(val_str), "/", &stream->avg_frame_rate)); + if (dec_ctx->bit_rate) + probe_str("bit_rate", + value_string(val_str, sizeof(val_str), + dec_ctx->bit_rate, unit_bit_per_second_str)); probe_str("time_base", rational_string(val_str, sizeof(val_str), "/", &stream->time_base)); From 0b300daad2f5cb59a7c06dde5ac701685e6edf16 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Wed, 21 Nov 2012 19:41:59 +0100 Subject: [PATCH 3/3] h264: error out on unset current_picture_ptr for h->current_slice > 0 Fixes a segfault with fuzzed sample sample_varPAR_s11622_r001-02.avi. CC: libav-stable@libav.org --- libavcodec/h264.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/h264.c b/libavcodec/h264.c index e3075cbe6f..7bdd6f1ed2 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2624,6 +2624,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0) s->picture_structure = last_pic_structure; s->dropable = last_pic_dropable; return AVERROR_INVALIDDATA; + } else if (!s->current_picture_ptr) { + av_log(s->avctx, AV_LOG_ERROR, + "unset current_picture_ptr on %d. slice\n", + h0->current_slice + 1); + return AVERROR_INVALIDDATA; } } else { /* Shorten frame num gaps so we don't have to allocate reference