]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/pmpdec.c
build: Allow building old API/ABI libpostproc version
[ffmpeg] / libavformat / pmpdec.c
index ba4000335976f93b40d53406e7c9c63344c7f789..a57b66072e25af35b0fc645c1a6d95fd28771466 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "internal.h"
 
 typedef struct {
     int cur_stream;
@@ -38,7 +39,8 @@ static int pmp_probe(AVProbeData *p) {
     return 0;
 }
 
-static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) {
+static int pmp_header(AVFormatContext *s, AVFormatParameters *ap)
+{
     PMPContext *pmp = s->priv_data;
     AVIOContext *pb = s->pb;
     int tb_num, tb_den;
@@ -47,7 +49,7 @@ static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) {
     int srate, channels;
     int i;
     uint64_t pos;
-    AVStream *vst = av_new_stream(s, 0);
+    AVStream *vst = avformat_new_stream(s, NULL);
     if (!vst)
         return AVERROR(ENOMEM);
     vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -69,7 +71,7 @@ static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) {
 
     tb_num = avio_rl32(pb);
     tb_den = avio_rl32(pb);
-    av_set_pts_info(vst, 32, tb_num, tb_den);
+    avpriv_set_pts_info(vst, 32, tb_num, tb_den);
     vst->nb_frames = index_cnt;
     vst->duration = index_cnt;
 
@@ -90,14 +92,14 @@ static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) {
     srate = avio_rl32(pb);
     channels = avio_rl32(pb) + 1;
     for (i = 1; i < pmp->num_streams; i++) {
-        AVStream *ast = av_new_stream(s, i);
+        AVStream *ast = avformat_new_stream(s, NULL);
         if (!ast)
             return AVERROR(ENOMEM);
         ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
         ast->codec->codec_id = audio_codec_id;
         ast->codec->channels = channels;
         ast->codec->sample_rate = srate;
-        av_set_pts_info(ast, 32, 1, srate);
+        avpriv_set_pts_info(ast, 32, 1, srate);
     }
     pos = avio_tell(pb) + 4*index_cnt;
     for (i = 0; i < index_cnt; i++) {
@@ -110,7 +112,8 @@ static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) {
     return 0;
 }
 
-static int pmp_packet(AVFormatContext *s, AVPacket *pkt) {
+static int pmp_packet(AVFormatContext *s, AVPacket *pkt)
+{
     PMPContext *pmp = s->priv_data;
     AVIOContext *pb = s->pb;
     int ret = 0;
@@ -127,14 +130,18 @@ static int pmp_packet(AVFormatContext *s, AVPacket *pkt) {
         av_fast_malloc(&pmp->packet_sizes,
                        &pmp->packet_sizes_alloc,
                        num_packets * sizeof(*pmp->packet_sizes));
+        if (!pmp->packet_sizes_alloc) {
+            av_log(s, AV_LOG_ERROR, "Cannot (re)allocate packet buffer\n");
+            return AVERROR(ENOMEM);
+        }
         for (i = 0; i < num_packets; i++)
             pmp->packet_sizes[i] = avio_rl32(pb);
     }
     ret = av_get_packet(pb, pkt, pmp->packet_sizes[pmp->current_packet]);
     if (ret >= 0) {
         ret = 0;
-        // FIXME: this is a hack that should be remove once
-        // compute_pkt_fields can handle
+        // FIXME: this is a hack that should be removed once
+        // compute_pkt_fields() can handle timestamps properly
         if (pmp->cur_stream == 0)
             pkt->dts = s->streams[0]->cur_dts++;
         pkt->stream_index = pmp->cur_stream;
@@ -145,8 +152,8 @@ static int pmp_packet(AVFormatContext *s, AVPacket *pkt) {
     return ret;
 }
 
-static int pmp_seek(AVFormatContext *s, int stream_index,
-                     int64_t ts, int flags) {
+static int pmp_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
+{
     PMPContext *pmp = s->priv_data;
     pmp->cur_stream = 0;
     // fallback to default seek now