X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fpmpdec.c;h=a57b66072e25af35b0fc645c1a6d95fd28771466;hb=7feb7f16a80a8d8754d2b32228f08470ecee2dca;hp=88b8998ad914e582d1c92b7415692c10b79ac7e4;hpb=d8cab5c26b0987f139830937e1f30b2a10822680;p=ffmpeg diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c index 88b8998ad91..a57b66072e2 100644 --- a/libavformat/pmpdec.c +++ b/libavformat/pmpdec.c @@ -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; @@ -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; @@ -93,12 +95,11 @@ static int pmp_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - ast->id = i; 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++) { @@ -111,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; @@ -128,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; @@ -146,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