]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/lxfdec.c
avisynth: Simplify shared library name construction
[ffmpeg] / libavformat / lxfdec.c
index cae954f1f6160c8f568aa4cc79ffd5f024863d14..e25f82e0af33742bf5583da18adb442f37b5191e 100644 (file)
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
@@ -44,7 +46,7 @@ static const AVCodecTag lxf_tags[] = {
     { AV_CODEC_ID_NONE,        0 },
 };
 
-typedef struct {
+typedef struct LXFDemuxContext {
     int channels;                       ///< number of audio channels. zero means no audio
     int frame_number;                   ///< current video frame
     uint32_t video_format, packet_type, extended_size;
@@ -128,12 +130,12 @@ static int get_packet_header(AVFormatContext *s)
     version     = bytestream_get_le32(&p);
     header_size = bytestream_get_le32(&p);
     if (version > 1)
-        avpriv_request_sample(s, "Unknown format version %i\n", version);
+        avpriv_request_sample(s, "Unknown format version %"PRIu32"\n", version);
 
     if (header_size < (version ? 72 : 60) ||
         header_size > LXF_MAX_PACKET_HEADER_SIZE ||
         (header_size & 3)) {
-        av_log(s, AV_LOG_ERROR, "Invalid header size 0x%x\n", header_size);
+        av_log(s, AV_LOG_ERROR, "Invalid header size 0x%"PRIx32"\n", header_size);
         return AVERROR_INVALIDDATA;
     }
 
@@ -160,7 +162,7 @@ static int get_packet_header(AVFormatContext *s)
         break;
     case 1:
         //audio
-        if (!(st = s->streams[1])) {
+        if (s->nb_streams < 2) {
             av_log(s, AV_LOG_INFO, "got audio packet, but no audio stream present\n");
             break;
         }
@@ -171,6 +173,8 @@ static int get_packet_header(AVFormatContext *s)
         channels     = bytestream_get_le32(&p);
         track_size   = bytestream_get_le32(&p);
 
+        st = s->streams[1];
+
         //set codec based on specified audio bitdepth
         //we only support tightly packed 16-, 20-, 24- and 32-bit PCM at the moment
         st->codec->bits_per_coded_sample = (audio_format >> 6) & 0x3F;
@@ -288,7 +292,6 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     LXFDemuxContext *lxf = s->priv_data;
     AVIOContext   *pb  = s->pb;
-    AVStream *ast = NULL;
     uint32_t stream;
     int ret, ret2;
 
@@ -298,11 +301,12 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
     stream = lxf->packet_type;
 
     if (stream > 1) {
-        av_log(s, AV_LOG_WARNING, "got packet with illegal stream index %u\n", stream);
+        av_log(s, AV_LOG_WARNING,
+               "got packet with illegal stream index %"PRIu32"\n", stream);
         return AVERROR(EAGAIN);
     }
 
-    if (stream == 1 && !(ast = s->streams[1])) {
+    if (stream == 1 && s->nb_streams < 2) {
         av_log(s, AV_LOG_ERROR, "got audio packet without having an audio stream\n");
         return AVERROR_INVALIDDATA;
     }
@@ -317,7 +321,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = stream;
 
-    if (!ast) {
+    if (!stream) {
         //picture type (0 = closed I, 1 = open I, 2 = P, 3 = B)
         if (((lxf->video_format >> 22) & 0x3) < 2)
             pkt->flags |= AV_PKT_FLAG_KEY;