]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xsubdec.c
h264: allocate hwaccel privdata after the frame buffer
[ffmpeg] / libavcodec / xsubdec.c
index 0791fdd05cfa45dbca38942ffa84c84db74cac70..11e1d57fed86dfea66c48a907ddf7f5f214ca6d2 100644 (file)
@@ -26,7 +26,7 @@
 #include "bytestream.h"
 
 static av_cold int decode_init(AVCodecContext *avctx) {
-    avctx->pix_fmt = PIX_FMT_PAL8;
+    avctx->pix_fmt = AV_PIX_FMT_PAL8;
     return 0;
 }
 
@@ -53,7 +53,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     AVSubtitle *sub = data;
     const uint8_t *buf_end = buf + buf_size;
     uint8_t *bitmap;
-    int w, h, x, y, rlelen, i;
+    int w, h, x, y, i;
     int64_t packet_time = 0;
     GetBitContext gb;
 
@@ -86,7 +86,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     // skip bottom right position, it gives no new information
     bytestream_get_le16(&buf);
     bytestream_get_le16(&buf);
-    rlelen = bytestream_get_le16(&buf);
+    // The following value is supposed to indicate the start offset
+    // (relative to the palette) of the data for the second field,
+    // however there are files in which it has a bogus value and thus
+    // we just ignore it
+    bytestream_get_le16(&buf);
 
     // allocate sub and set values
     sub->rects =  av_mallocz(sizeof(*sub->rects));
@@ -108,8 +112,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= 0xff000000;
 
     // process RLE-compressed data
-    rlelen = FFMIN(rlelen, buf_end - buf);
-    init_get_bits(&gb, buf, rlelen * 8);
+    init_get_bits(&gb, buf, (buf_end - buf) * 8);
     bitmap = sub->rects[0]->pict.data[0];
     for (y = 0; y < h; y++) {
         // interlaced: do odd lines
@@ -134,10 +137,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
 }
 
 AVCodec ff_xsub_decoder = {
-    .name           = "xsub",
-    .type           = AVMEDIA_TYPE_SUBTITLE,
-    .id             = CODEC_ID_XSUB,
-    .init           = decode_init,
-    .decode         = decode_frame,
+    .name      = "xsub",
+    .type      = AVMEDIA_TYPE_SUBTITLE,
+    .id        = AV_CODEC_ID_XSUB,
+    .init      = decode_init,
+    .decode    = decode_frame,
     .long_name = NULL_IF_CONFIG_SMALL("XSUB"),
 };