]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/idcin.c
hwcontext_vaapi: Return all formats for constraints without config
[ffmpeg] / libavformat / idcin.c
index b7e87a719a9ecd4d0f77a732f8bd720ca6e83791..86e9f41e0b117da64216ea6892e283febbf9cc13 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * id Quake II CIN File Demuxer
- * Copyright (c) 2003 The ffmpeg Project
+ * Copyright (c) 2003 The FFmpeg project
  *
  * This file is part of Libav.
  *
@@ -33,7 +33,7 @@
  * types. However, a CIN file does start with 5 32-bit numbers that
  * specify audio and video parameters. This demuxer gets around the lack
  * of file signature by performing sanity checks on those parameters.
- * Probabalistically, this is a reasonable solution since the number of
+ * Probabilistically, this is a reasonable solution since the number of
  * valid combinations of the 5 parameters is a very small subset of the
  * total 160-bit number space.
  *
@@ -68,7 +68,7 @@
  *       transmitting them to the video decoder
  */
 
-#include "libavutil/audioconvert.h"
+#include "libavutil/channel_layout.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
@@ -136,8 +136,8 @@ static int idcin_probe(AVProbeData *p)
     if (number > 2)
         return 0;
 
-    /* return half certainly since this check is a bit sketchy */
-    return AVPROBE_SCORE_MAX / 2;
+    /* return half certainty since this check is a bit sketchy */
+    return AVPROBE_SCORE_EXTENSION;
 }
 
 static int idcin_read_header(AVFormatContext *s)
@@ -189,16 +189,16 @@ static int idcin_read_header(AVFormatContext *s)
     avpriv_set_pts_info(st, 33, 1, IDCIN_FPS);
     st->start_time = 0;
     idcin->video_stream_index = st->index;
-    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id = AV_CODEC_ID_IDCIN;
-    st->codec->codec_tag = 0;  /* no fourcc */
-    st->codec->width = width;
-    st->codec->height = height;
+    st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+    st->codecpar->codec_id = AV_CODEC_ID_IDCIN;
+    st->codecpar->codec_tag = 0;  /* no fourcc */
+    st->codecpar->width = width;
+    st->codecpar->height = height;
 
     /* load up the Huffman tables into extradata */
-    st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
-    st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
-    ret = avio_read(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE);
+    st->codecpar->extradata_size = HUFFMAN_TABLE_SIZE;
+    st->codecpar->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
+    ret = avio_read(pb, st->codecpar->extradata, HUFFMAN_TABLE_SIZE);
     if (ret < 0) {
         return ret;
     } else if (ret != HUFFMAN_TABLE_SIZE) {
@@ -214,19 +214,19 @@ static int idcin_read_header(AVFormatContext *s)
         avpriv_set_pts_info(st, 63, 1, sample_rate);
         st->start_time = 0;
         idcin->audio_stream_index = st->index;
-        st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-        st->codec->codec_tag = 1;
-        st->codec->channels = channels;
-        st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
-                                                   AV_CH_LAYOUT_MONO;
-        st->codec->sample_rate = sample_rate;
-        st->codec->bits_per_coded_sample = bytes_per_sample * 8;
-        st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
-        st->codec->block_align = idcin->block_align = bytes_per_sample * channels;
+        st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+        st->codecpar->codec_tag = 1;
+        st->codecpar->channels = channels;
+        st->codecpar->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
+                                                      AV_CH_LAYOUT_MONO;
+        st->codecpar->sample_rate = sample_rate;
+        st->codecpar->bits_per_coded_sample = bytes_per_sample * 8;
+        st->codecpar->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
+        st->codecpar->block_align = idcin->block_align = bytes_per_sample * channels;
         if (bytes_per_sample == 1)
-            st->codec->codec_id = AV_CODEC_ID_PCM_U8;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
         else
-            st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+            st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 
         if (sample_rate % 14 != 0) {
             idcin->audio_chunk_size1 = (sample_rate / 14) *
@@ -309,6 +309,7 @@ static int idcin_read_packet(AVFormatContext *s,
             return ret;
         else if (ret != chunk_size) {
             av_log(s, AV_LOG_ERROR, "incomplete packet\n");
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         if (command == 1) {
@@ -316,8 +317,10 @@ static int idcin_read_packet(AVFormatContext *s,
 
             pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
                                           AVPALETTE_SIZE);
-            if (ret < 0)
-                return ret;
+            if (!pal) {
+                av_packet_unref(pkt);
+                return AVERROR(ENOMEM);
+            }
             memcpy(pal, palette, AVPALETTE_SIZE);
             pkt->flags |= AV_PKT_FLAG_KEY;
         }