]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/bintext.c
Merge commit '5b9cdf8cba114c41239bf0f9f5e0ccb6977d1c8d'
[ffmpeg] / libavformat / bintext.c
index 217ea49247a539969bb19db4cfa13c4da493eb70..3a24c811ef63d8451e235748eb1e864887d733b6 100644 (file)
@@ -54,12 +54,12 @@ static AVStream * init_stream(AVFormatContext *s)
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
         return NULL;
-    st->codec->codec_tag   = 0;
-    st->codec->codec_type  = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_tag   = 0;
+    st->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
 
     if (!bin->width) {
-        st->codec->width  = (80<<3);
-        st->codec->height = (25<<4);
+        st->codecpar->width  = (80<<3);
+        st->codecpar->height = (25<<4);
     }
 
     avpriv_set_pts_info(st, 60, bin->framerate.den, bin->framerate.num);
@@ -74,9 +74,9 @@ static AVStream * init_stream(AVFormatContext *s)
 /**
  * Given filesize and width, calculate height (assume font_height of 16)
  */
-static void calculate_height(AVCodecContext *avctx, uint64_t fsize)
+static void calculate_height(AVCodecParameters *par, uint64_t fsize)
 {
-    avctx->height = (fsize / ((avctx->width>>3)*2)) << 4;
+    par->height = (fsize / ((par->width>>3)*2)) << 4;
 }
 #endif
 
@@ -119,11 +119,11 @@ static int next_tag_read(AVFormatContext *avctx, uint64_t *fsize)
     return 0;
 }
 
-static void predict_width(AVCodecContext *avctx, uint64_t fsize, int got_width)
+static void predict_width(AVCodecParameters *par, uint64_t fsize, int got_width)
 {
     /** attempt to guess width */
     if (!got_width)
-        avctx->width = fsize > 4000 ? (160<<3) : (80<<3);
+        par->width = fsize > 4000 ? (160<<3) : (80<<3);
 }
 
 static int bintext_read_header(AVFormatContext *s)
@@ -134,12 +134,12 @@ static int bintext_read_header(AVFormatContext *s)
     AVStream *st = init_stream(s);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_id    = AV_CODEC_ID_BINTEXT;
+    st->codecpar->codec_id    = AV_CODEC_ID_BINTEXT;
 
-    if (ff_alloc_extradata(st->codec, 2))
+    if (ff_alloc_extradata(st->codecpar, 2))
         return AVERROR(ENOMEM);
-    st->codec->extradata[0] = 16;
-    st->codec->extradata[1] = 0;
+    st->codecpar->extradata[0] = 16;
+    st->codecpar->extradata[1] = 0;
 
     if (pb->seekable) {
         int got_width = 0;
@@ -147,8 +147,8 @@ static int bintext_read_header(AVFormatContext *s)
         if (ff_sauce_read(s, &bin->fsize, &got_width, 0) < 0)
             next_tag_read(s, &bin->fsize);
         if (!bin->width) {
-            predict_width(st->codec, bin->fsize, got_width);
-            calculate_height(st->codec, bin->fsize);
+            predict_width(st->codecpar, bin->fsize, got_width);
+            calculate_height(st->codecpar, bin->fsize);
         }
         avio_seek(pb, 0, SEEK_SET);
     }
@@ -179,30 +179,30 @@ static int xbin_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     avio_skip(pb, 5);
-    st->codec->width   = avio_rl16(pb)<<3;
-    st->codec->height  = avio_rl16(pb);
+    st->codecpar->width   = avio_rl16(pb)<<3;
+    st->codecpar->height  = avio_rl16(pb);
     fontheight         = avio_r8(pb);
-    st->codec->height *= fontheight;
+    st->codecpar->height *= fontheight;
     flags              = avio_r8(pb);
 
-    st->codec->extradata_size = 2;
+    st->codecpar->extradata_size = 2;
     if ((flags & BINTEXT_PALETTE))
-        st->codec->extradata_size += 48;
+        st->codecpar->extradata_size += 48;
     if ((flags & BINTEXT_FONT))
-        st->codec->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
-    st->codec->codec_id    = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
+        st->codecpar->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
+    st->codecpar->codec_id    = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
 
-    if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
+    if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size))
         return AVERROR(ENOMEM);
-    st->codec->extradata[0] = fontheight;
-    st->codec->extradata[1] = flags;
-    if (avio_read(pb, st->codec->extradata + 2, st->codec->extradata_size - 2) < 0)
+    st->codecpar->extradata[0] = fontheight;
+    st->codecpar->extradata[1] = flags;
+    if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0)
         return AVERROR(EIO);
 
     if (pb->seekable) {
-        bin->fsize = avio_size(pb) - 9 - st->codec->extradata_size;
+        bin->fsize = avio_size(pb) - 9 - st->codecpar->extradata_size;
         ff_sauce_read(s, &bin->fsize, NULL, 0);
-        avio_seek(pb, 9 + st->codec->extradata_size, SEEK_SET);
+        avio_seek(pb, 9 + st->codecpar->extradata_size, SEEK_SET);
     }
 
     return 0;
@@ -222,28 +222,28 @@ static int adf_read_header(AVFormatContext *s)
     st = init_stream(s);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_id    = AV_CODEC_ID_BINTEXT;
+    st->codecpar->codec_id    = AV_CODEC_ID_BINTEXT;
 
-    if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
+    if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
         return AVERROR(ENOMEM);
-    st->codec->extradata[0] = 16;
-    st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
+    st->codecpar->extradata[0] = 16;
+    st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
 
-    if (avio_read(pb, st->codec->extradata + 2, 24) < 0)
+    if (avio_read(pb, st->codecpar->extradata + 2, 24) < 0)
         return AVERROR(EIO);
     avio_skip(pb, 144);
-    if (avio_read(pb, st->codec->extradata + 2 + 24, 24) < 0)
+    if (avio_read(pb, st->codecpar->extradata + 2 + 24, 24) < 0)
         return AVERROR(EIO);
-    if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
+    if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
         return AVERROR(EIO);
 
     if (pb->seekable) {
         int got_width = 0;
         bin->fsize = avio_size(pb) - 1 - 192 - 4096;
-        st->codec->width = 80<<3;
+        st->codecpar->width = 80<<3;
         ff_sauce_read(s, &bin->fsize, &got_width, 0);
         if (!bin->width)
-            calculate_height(st->codec, bin->fsize);
+            calculate_height(st->codecpar, bin->fsize);
         avio_seek(pb, 1 + 192 + 4096, SEEK_SET);
     }
     return 0;
@@ -277,24 +277,24 @@ static int idf_read_header(AVFormatContext *s)
     st = init_stream(s);
     if (!st)
         return AVERROR(ENOMEM);
-    st->codec->codec_id    = AV_CODEC_ID_IDF;
+    st->codecpar->codec_id    = AV_CODEC_ID_IDF;
 
-    if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
+    if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
         return AVERROR(ENOMEM);
-    st->codec->extradata[0] = 16;
-    st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
+    st->codecpar->extradata[0] = 16;
+    st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
 
     avio_seek(pb, avio_size(pb) - 4096 - 48, SEEK_SET);
 
-    if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
+    if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
         return AVERROR(EIO);
-    if (avio_read(pb, st->codec->extradata + 2, 48) < 0)
+    if (avio_read(pb, st->codecpar->extradata + 2, 48) < 0)
         return AVERROR(EIO);
 
     bin->fsize = avio_size(pb) - 12 - 4096 - 48;
     ff_sauce_read(s, &bin->fsize, &got_width, 0);
     if (!bin->width)
-        calculate_height(st->codec, bin->fsize);
+        calculate_height(st->codecpar, bin->fsize);
     avio_seek(pb, 12, SEEK_SET);
     return 0;
 }