Ticket #4876: 0001-dnxhddec-skip-an-unknown-bit.patch

File 0001-dnxhddec-skip-an-unknown-bit.patch, 3.2 KB (added by Christophe, 11 years ago)

Now with 100% more interlaced mbs

  • libavcodec/dnxhddec.c

    From 8e036016fa93033404d2b08db970ceb7ce589122 Mon Sep 17 00:00:00 2001
    From: Christophe Gisquet <christophe.gisquet@gmail.com>
    Date: Thu, 24 Sep 2015 09:04:48 +0200
    Subject: [PATCH] dnxhddec: skip an unknown bit
    
    This bit is 1 in some samples, and seems to coincide with interlaced
    mbs. Currently, it leads to an obviously incorrect qscale value;
    The encoder writes 12 bits of syntax, last bit always 0, which is now
    somewhat inconsistent, but ends up with the same effect. The encoder
    does not attempt to encode as interlaced content.
    
    The qscale syntax in general seems oversized, maybe to support higher
    bitdepths.
    
    Fixes ticket #4876.
    ---
     libavcodec/dnxhddec.c | 13 +++++++++----
     1 file changed, 9 insertions(+), 4 deletions(-)
    
    diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
    index ccb61eb..4270b69 100644
    a b static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,  
    348348    uint8_t *dest_y, *dest_u, *dest_v;
    349349    int dct_y_offset, dct_x_offset;
    350350    int qscale, i;
     351    int interlaced_mb = get_bits1(&ctx->gb);
    351352
    352     qscale = get_bits(&ctx->gb, 11);
     353    qscale = get_bits(&ctx->gb, 10);
    353354    skip_bits1(&ctx->gb);
    354355
    355356    if (qscale != ctx->last_qscale) {
    static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,  
    385386        dest_u += frame->linesize[1];
    386387        dest_v += frame->linesize[2];
    387388    }
     389    if (interlaced_mb) {
     390        dct_linesize_luma   <<= 1;
     391        dct_linesize_chroma <<= 1;
     392    }
    388393
    389     dct_y_offset = dct_linesize_luma << 3;
     394    dct_y_offset = interlaced_mb ? frame->linesize[0] : (dct_linesize_luma << 3);
    390395    dct_x_offset = 8 << shift1;
    391396    if (!ctx->is_444) {
    392397        ctx->idsp.idct_put(dest_y,                               dct_linesize_luma, ctx->blocks[0]);
    static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,  
    395400        ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[5]);
    396401
    397402        if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) {
    398             dct_y_offset = dct_linesize_chroma << 3;
     403            dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3);
    399404            ctx->idsp.idct_put(dest_u,                dct_linesize_chroma, ctx->blocks[2]);
    400405            ctx->idsp.idct_put(dest_v,                dct_linesize_chroma, ctx->blocks[3]);
    401406            ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, ctx->blocks[6]);
    static int dnxhd_decode_macroblock(DNXHDContext *ctx, AVFrame *frame,  
    408413        ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, ctx->blocks[7]);
    409414
    410415        if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) {
    411             dct_y_offset = dct_linesize_chroma << 3;
     416            dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3);
    412417            ctx->idsp.idct_put(dest_u,                               dct_linesize_chroma, ctx->blocks[2]);
    413418            ctx->idsp.idct_put(dest_u + dct_x_offset,                dct_linesize_chroma, ctx->blocks[3]);
    414419            ctx->idsp.idct_put(dest_u + dct_y_offset,                dct_linesize_chroma, ctx->blocks[8]);