]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tta.c
libavformat: Add a flag for muxers that support write_packet(NULL) for flushing
[ffmpeg] / libavformat / tta.c
index d049d5e9c703a27b861e95f3dfe2329ea04a6a11..6bf097975a616afaaa8754bb8364dc7573131fb9 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "libavcodec/get_bits.h"
 #include "avformat.h"
+#include "internal.h"
 #include "id3v1.h"
 #include "libavutil/dict.h"
 
@@ -77,11 +78,11 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
         return -1;
     }
 
-    st = av_new_stream(s, 0);
+    st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
 
-    av_set_pts_info(st, 64, 1, samplerate);
+    avpriv_set_pts_info(st, 64, 1, samplerate);
     st->start_time = 0;
     st->duration = datalen;
 
@@ -107,6 +108,10 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
         return -1;
     }
     st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
+    if (!st->codec->extradata) {
+        st->codec->extradata_size = 0;
+        return AVERROR(ENOMEM);
+    }
     avio_seek(s->pb, start_offset, SEEK_SET);
     avio_read(s->pb, st->codec->extradata, st->codec->extradata_size);
 
@@ -120,8 +125,8 @@ static int tta_read_packet(AVFormatContext *s, AVPacket *pkt)
     int size, ret;
 
     // FIXME!
-    if (c->currentframe > c->totalframes)
-        return -1;
+    if (c->currentframe >= c->totalframes)
+        return AVERROR_EOF;
 
     size = st->index_entries[c->currentframe].size;