]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tmv.c
lavc: Remove old vaapi decode infrastructure
[ffmpeg] / libavformat / tmv.c
index 73b44bbc1dc8be92cc389763e4c70c1ddc0f73c2..0283ddaad9ccb52fd44e17aeca4f75bc8890967f 100644 (file)
@@ -26,6 +26,7 @@
  * @see http://www.oldskool.org/pc/8088_Corruption
  */
 
+#include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -63,7 +64,7 @@ static int tmv_probe(AVProbeData *p)
     return 0;
 }
 
-static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
+static int tmv_read_header(AVFormatContext *s)
 {
     TMVContext *tmv   = s->priv_data;
     AVIOContext *pb = s->pb;
@@ -80,8 +81,8 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
     if (!(ast = avformat_new_stream(s, NULL)))
         return AVERROR(ENOMEM);
 
-    ast->codec->sample_rate = avio_rl16(pb);
-    if (!ast->codec->sample_rate) {
+    ast->codecpar->sample_rate = avio_rl16(pb);
+    if (!ast->codecpar->sample_rate) {
         av_log(s, AV_LOG_ERROR, "invalid sample rate\n");
         return -1;
     }
@@ -110,23 +111,29 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
         return -1;
     }
 
-    ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
-    ast->codec->codec_id              = CODEC_ID_PCM_U8;
-    ast->codec->channels              = features & TMV_STEREO ? 2 : 1;
-    ast->codec->bits_per_coded_sample = 8;
-    ast->codec->bit_rate              = ast->codec->sample_rate *
-                                        ast->codec->bits_per_coded_sample;
-    avpriv_set_pts_info(ast, 32, 1, ast->codec->sample_rate);
+    ast->codecpar->codec_type            = AVMEDIA_TYPE_AUDIO;
+    ast->codecpar->codec_id              = AV_CODEC_ID_PCM_U8;
+    if (features & TMV_STEREO) {
+        ast->codecpar->channels       = 2;
+        ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+    } else {
+        ast->codecpar->channels       = 1;
+        ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+    }
+    ast->codecpar->bits_per_coded_sample = 8;
+    ast->codecpar->bit_rate              = ast->codecpar->sample_rate *
+                                           ast->codecpar->bits_per_coded_sample;
+    avpriv_set_pts_info(ast, 32, 1, ast->codecpar->sample_rate);
 
-    fps.num = ast->codec->sample_rate * ast->codec->channels;
+    fps.num = ast->codecpar->sample_rate * ast->codecpar->channels;
     fps.den = tmv->audio_chunk_size;
     av_reduce(&fps.num, &fps.den, fps.num, fps.den, 0xFFFFFFFFLL);
 
-    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    vst->codec->codec_id   = CODEC_ID_TMV;
-    vst->codec->pix_fmt    = PIX_FMT_PAL8;
-    vst->codec->width      = char_cols * 8;
-    vst->codec->height     = char_rows * 8;
+    vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    vst->codecpar->codec_id   = AV_CODEC_ID_TMV;
+    vst->codecpar->format     = AV_PIX_FMT_PAL8;
+    vst->codecpar->width      = char_cols * 8;
+    vst->codecpar->height     = char_rows * 8;
     avpriv_set_pts_info(vst, 32, fps.den, fps.num);
 
     if (features & TMV_PADDING)
@@ -134,8 +141,8 @@ static int tmv_read_header(AVFormatContext *s, AVFormatParameters *ap)
             ((tmv->video_chunk_size + tmv->audio_chunk_size + 511) & ~511) -
              (tmv->video_chunk_size + tmv->audio_chunk_size);
 
-    vst->codec->bit_rate = ((tmv->video_chunk_size + tmv->padding) *
-                            fps.num * 8) / fps.den;
+    vst->codecpar->bit_rate = ((tmv->video_chunk_size + tmv->padding) *
+                               fps.num * 8) / fps.den;
 
     return 0;
 }
@@ -174,7 +181,8 @@ static int tmv_read_seek(AVFormatContext *s, int stream_index,
     pos = timestamp *
           (tmv->audio_chunk_size + tmv->video_chunk_size + tmv->padding);
 
-    avio_seek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET);
+    if (avio_seek(s->pb, pos + TMV_HEADER_SIZE, SEEK_SET) < 0)
+        return -1;
     tmv->stream_index = 0;
     return 0;
 }
@@ -187,5 +195,5 @@ AVInputFormat ff_tmv_demuxer = {
     .read_header    = tmv_read_header,
     .read_packet    = tmv_read_packet,
     .read_seek      = tmv_read_seek,
-    .flags = AVFMT_GENERIC_INDEX,
+    .flags          = AVFMT_GENERIC_INDEX,
 };