From 901682ff78da014774b17947c5d83fdeaec27204 Mon Sep 17 00:00:00 2001 From: Michael Karcher Date: Fri, 25 Jan 2013 15:03:53 -0500 Subject: [PATCH 1/4] atrac3: use correct loop variable in add_tonal_components() Signed-off-by: Michael Karcher Signed-off-by: Justin Ruggles CC:libav-stable@libav.org (cherry picked from commit 0e3afacd4d8fbe1c21e0bc16bd707809cd87380f) Signed-off-by: Reinhard Tartler --- libavcodec/atrac3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 312b283883..a46b0b1277 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -517,7 +517,7 @@ static int add_tonal_components(float *spectrum, int num_components, output = &spectrum[components[i].pos]; for (j = 0; j < components[i].num_coefs; j++) - output[i] += input[i]; + output[j] += input[j]; } return last_pos; From e0e42504219370d85d5e93590e361877338090eb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 22 Jan 2013 11:55:54 +0100 Subject: [PATCH 2/4] dnxhdenc: fix invalid reads in dnxhd_mb_var_thread(). Do not assume that frame dimensions are mod16 (or that height is mod32 for interlaced). CC:libav-stable@libav.org (cherry picked from commit 69c25c9284645cf5189af2ede42d6f53828f3b45) Signed-off-by: Reinhard Tartler --- libavcodec/dnxhdenc.c | 27 ++++++++++++++++++++++++--- tests/ref/vsynth/vsynth1-dnxhd-1080i | 4 ++-- tests/ref/vsynth/vsynth2-dnxhd-1080i | 4 ++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 8531fe0ea5..97e0fede2f 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -615,14 +615,35 @@ static void dnxhd_setup_threads_slices(DNXHDEncContext *ctx) static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { DNXHDEncContext *ctx = avctx->priv_data; - int mb_y = jobnr, mb_x; + int mb_y = jobnr, mb_x, x, y; + int partial_last_row = (mb_y == ctx->m.mb_height - 1) && + ((avctx->height >> ctx->interlaced) & 0xF); + ctx = ctx->thread[threadnr]; if (ctx->cid_table->bit_depth == 8) { uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y<<4) * ctx->m.linesize); for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; - int sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); - int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)sum*sum)>>8)+128)>>8; + int sum; + int varc; + + if (!partial_last_row && mb_x * 16 <= avctx->width - 16) { + sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); + varc = ctx->m.dsp.pix_norm1(pix, ctx->m.linesize); + } else { + int bw = FFMIN(avctx->width - 16 * mb_x, 16); + int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16); + sum = varc = 0; + for (y = 0; y < bh; y++) { + for (x = 0; x < bw; x++) { + uint8_t val = pix[x + y * ctx->m.linesize]; + sum += val; + varc += val * val; + } + } + } + varc = (varc - (((unsigned)sum * sum) >> 8) + 128) >> 8; + ctx->mb_cmp[mb].value = varc; ctx->mb_cmp[mb].mb = mb; } diff --git a/tests/ref/vsynth/vsynth1-dnxhd-1080i b/tests/ref/vsynth/vsynth1-dnxhd-1080i index 1eddbf8c4f..3a990c5657 100644 --- a/tests/ref/vsynth/vsynth1-dnxhd-1080i +++ b/tests/ref/vsynth/vsynth1-dnxhd-1080i @@ -1,4 +1,4 @@ -3cfbe36a7dd5b48859b8a569d626ef77 *tests/data/fate/vsynth1-dnxhd-1080i.mov +2412f206f5efcbbcc3f2bba0c86b73d4 *tests/data/fate/vsynth1-dnxhd-1080i.mov 3031875 tests/data/fate/vsynth1-dnxhd-1080i.mov -0c651e840f860592f0d5b66030d9fa32 *tests/data/fate/vsynth1-dnxhd-1080i.out.rawvideo +34076f61254997c8157eafed1c916472 *tests/data/fate/vsynth1-dnxhd-1080i.out.rawvideo stddev: 6.29 PSNR: 32.15 MAXDIFF: 64 bytes: 7603200/ 760320 diff --git a/tests/ref/vsynth/vsynth2-dnxhd-1080i b/tests/ref/vsynth/vsynth2-dnxhd-1080i index 41a8d51444..27c79a5ee9 100644 --- a/tests/ref/vsynth/vsynth2-dnxhd-1080i +++ b/tests/ref/vsynth/vsynth2-dnxhd-1080i @@ -1,4 +1,4 @@ -19a91b7da35cecf41e5e3cb322485627 *tests/data/fate/vsynth2-dnxhd-1080i.mov +65ca6385b565b6ea9a2e28150eef1d46 *tests/data/fate/vsynth2-dnxhd-1080i.mov 3031875 tests/data/fate/vsynth2-dnxhd-1080i.mov -3c559af629ae0a8fb1a9a0e4b4da7733 *tests/data/fate/vsynth2-dnxhd-1080i.out.rawvideo +42262a2325441b38b3b3c8a42d888e7d *tests/data/fate/vsynth2-dnxhd-1080i.out.rawvideo stddev: 1.31 PSNR: 45.77 MAXDIFF: 23 bytes: 7603200/ 760320 From e835ce83e2ac518fb1227351379f3c8c8cc9066a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Jan 2013 21:10:54 +0100 Subject: [PATCH 3/4] vf_delogo: fix an uninitialized read. CC:libav-stable@libav.org (cherry picked from commit f81c37e40fe3236d54da12aef9cdba48ba70ec31) Signed-off-by: Reinhard Tartler --- libavfilter/vf_delogo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 76848c3198..5d56444e20 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -223,7 +223,7 @@ static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in) AVFilterBufferRef *out; int hsub0 = desc->log2_chroma_w; int vsub0 = desc->log2_chroma_h; - int direct; + int direct = 0; int plane; if ((in->perms & AV_PERM_WRITE) && !(in->perms & AV_PERM_PRESERVE)) { From 5bee21d724dc47d115faae3f5065a6db74e1594a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 21 Jan 2013 21:48:49 +0100 Subject: [PATCH 4/4] vf_delogo: fix copying the input frame. CC:libav-stable@libav.org (cherry picked from commit 7194330bcd6db8dc5c22e0c162a0992d519307f9) Signed-off-by: Reinhard Tartler --- libavfilter/vf_delogo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 5d56444e20..af479c2b12 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -80,12 +80,12 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, topright = src+logo_y1 * src_linesize+logo_x2-1; botleft = src+(logo_y2-1) * src_linesize+logo_x1; - dst += (logo_y1+1)*dst_linesize; - src += (logo_y1+1)*src_linesize; - if (!direct) av_image_copy_plane(dst, dst_linesize, src, src_linesize, w, h); + dst += (logo_y1 + 1) * dst_linesize; + src += (logo_y1 + 1) * src_linesize; + for (y = logo_y1+1; y < logo_y2-1; y++) { for (x = logo_x1+1, xdst = dst+logo_x1+1,