summaryrefslogtreecommitdiff
path: root/libavcodec/dnxhddec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/dnxhddec.c')
-rw-r--r--libavcodec/dnxhddec.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 6928b32263..43c4679f69 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -2,20 +2,20 @@
* VC3/DNxHD decoder.
* Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -55,6 +55,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
ctx->avctx = avctx;
dsputil_init(&ctx->dsp, avctx);
avctx->coded_frame = &ctx->picture;
+ avcodec_get_frame_defaults(&ctx->picture);
ctx->picture.type = AV_PICTURE_TYPE_I;
ctx->picture.key_frame = 1;
return 0;
@@ -62,7 +63,7 @@ static av_cold int dnxhd_decode_init(AVCodecContext *avctx)
static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
{
- if (!ctx->cid_table) {
+ if (cid != ctx->cid) {
int index;
if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
@@ -70,6 +71,11 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
return -1;
}
ctx->cid_table = &ff_dnxhd_cid_table[index];
+
+ free_vlc(&ctx->ac_vlc);
+ free_vlc(&ctx->dc_vlc);
+ free_vlc(&ctx->run_vlc);
+
init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
ctx->cid_table->ac_bits, 1, 1,
ctx->cid_table->ac_codes, 2, 2, 0);
@@ -81,6 +87,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
ctx->cid_table->run_codes, 2, 2, 0);
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);
+ ctx->cid = cid;
}
return 0;
}
@@ -88,7 +95,7 @@ static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_size, int first_field)
{
static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 };
- int i;
+ int i, cid;
if (buf_size < 0x280)
return -1;
@@ -114,10 +121,10 @@ static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_si
return -1;
}
- ctx->cid = AV_RB32(buf + 0x28);
- av_dlog(ctx->avctx, "compression id %d\n", ctx->cid);
+ cid = AV_RB32(buf + 0x28);
+ av_dlog(ctx->avctx, "compression id %d\n", cid);
- if (dnxhd_init_vlc(ctx, ctx->cid) < 0)
+ if (dnxhd_init_vlc(ctx, cid) < 0)
return -1;
if (buf_size < ctx->cid_table->coding_unit_size) {