]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dnxhdenc.c
avcodec/takdec: Fix runtime error: left shift of negative value -42
[ffmpeg] / libavcodec / dnxhdenc.c
index 665a99270659aa48e7b6857836c73a79b5f431fb..59e3f73689f6826596585bc056874dbe3c2a3cc4 100644 (file)
@@ -362,13 +362,6 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-static int dnxhd_get_hr_frame_size(const CIDEntry* profile, int mb_num)
-{
-    int result = mb_num * profile->packet_scale.num / profile->packet_scale.den;
-    result = (result + 2048) / 4096 * 4096;
-    return FFMAX(result, 8192);
-}
-
 static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
 {
     DNXHDEncContext *ctx = avctx->priv_data;
@@ -483,8 +476,8 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx)
     ctx->m.mb_num = ctx->m.mb_height * ctx->m.mb_width;
 
     if (ctx->cid_table->frame_size == DNXHD_VARIABLE) {
-        ctx->frame_size = dnxhd_get_hr_frame_size(ctx->cid_table,
-                                                  ctx->m.mb_num);
+        ctx->frame_size = ff_dnxhd_get_hr_frame_size(ctx->cid,
+                                                     avctx->width, avctx->height);
         ctx->coding_unit_size = ctx->frame_size;
     } else {
         ctx->frame_size = ctx->cid_table->frame_size;
@@ -582,7 +575,7 @@ static int dnxhd_write_header(AVCodecContext *avctx, uint8_t *buf)
 
     buf[0x167] = 0x02; // reserved
     AV_WB16(buf + 0x16a, ctx->m.mb_height * 4 + 4); // MSIPS
-    buf[0x16d] = ctx->m.mb_height; // Ns
+    AV_WB16(buf + 0x16c, ctx->m.mb_height); // Ns
     buf[0x16f] = 0x10; // reserved
 
     ctx->msip = buf + 0x170;