#include "libavutil/intreadwrite.h"
#include "avformat.h"
+#include "internal.h"
typedef struct {
int cur_stream;
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;
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;
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++) {
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;
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;
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