]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mxg.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavformat / mxg.c
index e884311badd18dd6e8cf0c48083bad596b4f1e56..3e0c4219e4d0e9fbf0ee2b102d097c9f7c5bec60 100644 (file)
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/mjpeg.h"
 #include "avformat.h"
+#include "internal.h"
 #include "avio.h"
 
-#define VIDEO_STREAM_INDEX 0
-#define AUDIO_STREAM_INDEX 1
 #define DEFAULT_PACKET_SIZE 1024
 #define OVERREAD_SIZE 3
 
@@ -44,14 +43,14 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap)
     MXGContext *mxg = s->priv_data;
 
     /* video parameters will be extracted from the compressed bitstream */
-    video_st = av_new_stream(s, VIDEO_STREAM_INDEX);
+    video_st = avformat_new_stream(s, NULL);
     if (!video_st)
         return AVERROR(ENOMEM);
     video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     video_st->codec->codec_id = CODEC_ID_MXPEG;
-    av_set_pts_info(video_st, 64, 1, 1000000);
+    avpriv_set_pts_info(video_st, 64, 1, 1000000);
 
-    audio_st = av_new_stream(s, AUDIO_STREAM_INDEX);
+    audio_st = avformat_new_stream(s, NULL);
     if (!audio_st)
         return AVERROR(ENOMEM);
     audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
@@ -60,7 +59,7 @@ static int mxg_read_header(AVFormatContext *s, AVFormatParameters *ap)
     audio_st->codec->sample_rate = 8000;
     audio_st->codec->bits_per_coded_sample = 8;
     audio_st->codec->block_align = 1;
-    av_set_pts_info(audio_st, 64, 1, 1000000);
+    avpriv_set_pts_info(audio_st, 64, 1, 1000000);
 
     mxg->soi_ptr = mxg->buffer_ptr = mxg->buffer = 0;
     mxg->buffer_size = 0;
@@ -105,7 +104,7 @@ static int mxg_update_cache(AVFormatContext *s, unsigned int cache_size)
     /* reallocate internal buffer */
     if (current_pos > current_pos + cache_size)
         return AVERROR(ENOMEM);
-    if (mxg->soi_ptr) soi_pos = mxg->soi_ptr - mxg->buffer;
+    soi_pos = mxg->soi_ptr - mxg->buffer;
     mxg->buffer = av_fast_realloc(mxg->buffer, &mxg->buffer_size,
                                   current_pos + cache_size +
                                   FF_INPUT_BUFFER_PADDING_SIZE);
@@ -166,7 +165,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
                 }
 
                 pkt->pts = pkt->dts = mxg->dts;
-                pkt->stream_index = VIDEO_STREAM_INDEX;
+                pkt->stream_index = 0;
                 pkt->destruct = NULL;
                 pkt->size = mxg->buffer_ptr - mxg->soi_ptr;
                 pkt->data = mxg->soi_ptr;
@@ -204,7 +203,7 @@ static int mxg_read_packet(AVFormatContext *s, AVPacket *pkt)
                 if (marker == APP13 && size >= 16) { /* audio data */
                     /* time (GMT) of first sample in usec since 1970, little-endian */
                     pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8);
-                    pkt->stream_index = AUDIO_STREAM_INDEX;
+                    pkt->stream_index = 1;
                     pkt->destruct = NULL;
                     pkt->size = size - 14;
                     pkt->data = startmarker_ptr + 16;