]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/proresdec.c
cook: K&R formatting cosmetics
[ffmpeg] / libavcodec / proresdec.c
index ca465f4d8e3d0f52921b1dc7368dfec61bdb0d48..031760c3bba5710a12058ee3d06639c14144c47f 100644 (file)
@@ -28,7 +28,7 @@
  * @see http://wiki.multimedia.cx/index.php?title=Apple_ProRes
  */
 
-#define A32_BITSTREAM_READER // some ProRes vlc codes require up to 28 bits to be read at once
+#define LONG_BITSTREAM_READER // some ProRes vlc codes require up to 28 bits to be read at once
 
 #include <stdint.h>
 
@@ -499,8 +499,9 @@ static void decode_slice_plane(ProresContext *ctx, ProresThreadData *td,
 }
 
 
-static int decode_slice(AVCodecContext *avctx, ProresThreadData *td)
+static int decode_slice(AVCodecContext *avctx, void *tdata)
 {
+    ProresThreadData *td = tdata;
     ProresContext *ctx = avctx->priv_data;
     int mb_x_pos  = td->x_pos;
     int mb_y_pos  = td->y_pos;
@@ -546,9 +547,11 @@ static int decode_slice(AVCodecContext *avctx, ProresThreadData *td)
     hdr_size    = buf[0] >> 3;
     y_data_size = AV_RB16(buf + 2);
     u_data_size = AV_RB16(buf + 4);
-    v_data_size = slice_data_size - y_data_size - u_data_size - hdr_size;
+    v_data_size = hdr_size > 7 ? AV_RB16(buf + 6) :
+        slice_data_size - y_data_size - u_data_size - hdr_size;
 
-    if (v_data_size < 0 || hdr_size < 6) {
+    if (hdr_size + y_data_size + u_data_size + v_data_size > slice_data_size ||
+        v_data_size < 0 || hdr_size < 6) {
         av_log(avctx, AV_LOG_ERROR, "invalid data size\n");
         return AVERROR_INVALIDDATA;
     }
@@ -557,7 +560,7 @@ static int decode_slice(AVCodecContext *avctx, ProresThreadData *td)
     sf = sf > 128 ? (sf - 96) << 2 : sf;
 
     /* scale quantization matrixes according with slice's scale factor */
-    /* TODO: this can be SIMD-optimized alot */
+    /* TODO: this can be SIMD-optimized a lot */
     if (ctx->qmat_changed || sf != ctx->prev_slice_sf) {
         ctx->prev_slice_sf = sf;
         for (i = 0; i < 64; i++) {
@@ -619,7 +622,7 @@ static int decode_picture(ProresContext *ctx, int pic_num,
         }
     }
 
-    return avctx->execute(avctx, (void *) decode_slice,
+    return avctx->execute(avctx, decode_slice,
                           ctx->slice_data, NULL, slice_num,
                           sizeof(ctx->slice_data[0]));
 }