From f4d0a63b5b5c682c18df3bba730f97a9067408ba Mon Sep 17 00:00:00 2001 From: Claudio Freire Date: Sat, 4 May 2013 18:36:37 -0300 Subject: [PATCH 1/4] aacenc: Fix target bitrate for twoloop quantiser search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a case where multichannel bitrate isn't accurately targetted by psy model alone, never achieving the target bitrate. Signed-off-by: Martin Storsjö --- libavcodec/aaccoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index d65d8d9584..35b98a9ae2 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -710,7 +710,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, const float lambda) { int start = 0, i, w, w2, g; - int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; + int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels * (lambda / 120.f); float dists[128] = { 0 }, uplims[128]; float maxvals[128]; int fflag, minscaler; From 8bbdd20a293eab2cfac9f332613ead02a4e3c0c2 Mon Sep 17 00:00:00 2001 From: Claudio Freire Date: Sun, 12 May 2013 09:38:40 +0200 Subject: [PATCH 2/4] aacenc: Fix erasure of surround channels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was due to a miscomputation of s->cur_channel, which led to psy-based encoders using the psy coefficients for the wrong channel. Signed-off-by: Martin Storsjö --- libavcodec/aacenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 60eca59ae0..b2ad47bd75 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -597,7 +597,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, coeffs[ch] = cpe->ch[ch].coeffs; s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); for (ch = 0; ch < chans; ch++) { - s->cur_channel = start_ch * 2 + ch; + s->cur_channel = start_ch + ch; s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); } cpe->common_window = 0; @@ -613,7 +613,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } } } - s->cur_channel = start_ch * 2; + s->cur_channel = start_ch; if (s->options.stereo_mode && cpe->common_window) { if (s->options.stereo_mode > 0) { IndividualChannelStream *ics = &cpe->ch[0].ics; From 1bd57a850a659ac0fcd235efe2191d0b3f1b5d54 Mon Sep 17 00:00:00 2001 From: Sebastian Sandberg Date: Thu, 31 Jan 2013 18:04:21 +0100 Subject: [PATCH 3/4] vc1dec: fieldtx is only valid for interlaced frame pictures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fieldtx_plane is not cleared for interlaced fields. Signed-off-by: Martin Storsjö --- libavcodec/vc1dec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 04b7efbca3..c434f695da 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -80,7 +80,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) { MpegEncContext *s = &v->s; int topleft_mb_pos, top_mb_pos; - int stride_y, fieldtx; + int stride_y, fieldtx = 0; int v_dist; /* The put pixels loop is always one MB row behind the decoding loop, @@ -93,7 +93,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) if (!s->first_slice_line) { if (s->mb_x) { topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1; - fieldtx = v->fieldtx_plane[topleft_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[topleft_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = (16 - fieldtx) >> (fieldtx == 0); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], @@ -117,7 +118,8 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) } if (s->mb_x == s->mb_width - 1) { top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x; - fieldtx = v->fieldtx_plane[top_mb_pos]; + if (v->fcm == ILACE_FRAME) + fieldtx = v->fieldtx_plane[top_mb_pos]; stride_y = s->linesize << fieldtx; v_dist = fieldtx ? 15 : 8; s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], From 46430fd47c6239ef8742d0a34f9412d5060fa798 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 24 Jul 2012 04:05:18 +0200 Subject: [PATCH 4/4] vc1dec: Don't attempt error concealment on field pictures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not implemented and doesn't work. Signed-off-by: Martin Storsjö --- libavcodec/vc1dec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index c434f695da..994f5df52c 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -5630,7 +5630,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, get_bits_count(&s->gb), s->gb.size_in_bits); // if (get_bits_count(&s->gb) > buf_size * 8) // return -1; - ff_er_frame_end(&s->er); + if (!v->field_mode) + ff_er_frame_end(&s->er); } ff_MPV_frame_end(s);