summaryrefslogtreecommitdiff
path: root/libavformat/paf.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-03-28 04:31:42 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-03-28 04:32:05 +0100
commit16ddc58bd7a2f98b47fb2597a2b349d0aba82da4 (patch)
tree46f0b63bd1c9d5bd3970920226c12accc45845fb /libavformat/paf.c
parent03e4c2d8333d46c598856f218d9dfeb9316266d8 (diff)
parent70daeacd6ef8b354dd7d2d77ad393831a5bbf033 (diff)
Merge commit '70daeacd6ef8b354dd7d2d77ad393831a5bbf033'
* commit '70daeacd6ef8b354dd7d2d77ad393831a5bbf033': PAF demuxer and decoder Conflicts: Changelog doc/general.texi libavcodec/avcodec.h libavcodec/codec_desc.c libavcodec/paf.c libavcodec/version.h libavformat/Makefile libavformat/allformats.c libavformat/paf.c libavformat/version.h See: 7de4a16508cb9bd2d40855f7114dea14329ef62a, and others Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/paf.c')
-rw-r--r--libavformat/paf.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/libavformat/paf.c b/libavformat/paf.c
index 09aefe6770..88a274fe15 100644
--- a/libavformat/paf.c
+++ b/libavformat/paf.c
@@ -44,13 +44,13 @@ typedef struct {
uint32_t *blocks_offset_table;
uint8_t *video_frame;
- int video_size;
+ int video_size;
uint8_t *audio_frame;
uint8_t *temp_audio_frame;
- int audio_size;
+ int audio_size;
- int got_audio;
+ int got_audio;
} PAFDemuxContext;
static int read_probe(AVProbeData *p)
@@ -87,10 +87,10 @@ static void read_table(AVFormatContext *s, uint32_t *table, uint32_t count)
static int read_header(AVFormatContext *s)
{
- PAFDemuxContext *p = s->priv_data;
+ PAFDemuxContext *p = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *ast, *vst;
- int ret = 0;
+ int ret = 0;
avio_skip(pb, 132);
@@ -101,11 +101,13 @@ static int read_header(AVFormatContext *s)
vst->start_time = 0;
vst->nb_frames =
vst->duration =
- p->nb_frames = avio_rl32(pb);
+ p->nb_frames = avio_rl32(pb);
avio_skip(pb, 4);
+
vst->codec->width = avio_rl32(pb);
vst->codec->height = avio_rl32(pb);
avio_skip(pb, 4);
+
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_tag = 0;
vst->codec->codec_id = AV_CODEC_ID_PAF_VIDEO;
@@ -115,13 +117,13 @@ static int read_header(AVFormatContext *s)
if (!ast)
return AVERROR(ENOMEM);
- ast->start_time = 0;
- ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- ast->codec->codec_tag = 0;
- ast->codec->codec_id = AV_CODEC_ID_PAF_AUDIO;
- ast->codec->channels = 2;
+ ast->start_time = 0;
+ ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ ast->codec->codec_tag = 0;
+ ast->codec->codec_id = AV_CODEC_ID_PAF_AUDIO;
+ ast->codec->channels = 2;
ast->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- ast->codec->sample_rate = 22050;
+ ast->codec->sample_rate = 22050;
avpriv_set_pts_info(ast, 64, 1, 22050);
p->buffer_size = avio_rl32(pb);
@@ -143,16 +145,19 @@ static int read_header(AVFormatContext *s)
p->frame_blks > INT_MAX / sizeof(uint32_t))
return AVERROR_INVALIDDATA;
- p->blocks_count_table = av_mallocz(p->nb_frames * sizeof(uint32_t));
- p->frames_offset_table = av_mallocz(p->nb_frames * sizeof(uint32_t));
- p->blocks_offset_table = av_mallocz(p->frame_blks * sizeof(uint32_t));
+ p->blocks_count_table = av_mallocz(p->nb_frames *
+ sizeof(*p->blocks_count_table));
+ p->frames_offset_table = av_mallocz(p->nb_frames *
+ sizeof(*p->frames_offset_table));
+ p->blocks_offset_table = av_mallocz(p->frame_blks *
+ sizeof(*p->blocks_offset_table));
- p->video_size = p->max_video_blks * p->buffer_size;
- p->video_frame = av_mallocz(p->video_size);
+ p->video_size = p->max_video_blks * p->buffer_size;
+ p->video_frame = av_mallocz(p->video_size);
- p->audio_size = p->max_audio_blks * p->buffer_size;
- p->audio_frame = av_mallocz(p->audio_size);
- p->temp_audio_frame = av_mallocz(p->audio_size);
+ p->audio_size = p->max_audio_blks * p->buffer_size;
+ p->audio_frame = av_mallocz(p->audio_size);
+ p->temp_audio_frame = av_mallocz(p->audio_size);
if (!p->blocks_count_table ||
!p->frames_offset_table ||
@@ -186,7 +191,7 @@ fail:
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
- PAFDemuxContext *p = s->priv_data;
+ PAFDemuxContext *p = s->priv_data;
AVIOContext *pb = s->pb;
uint32_t count, offset;
int size, i;
@@ -209,7 +214,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return pkt->size;
}
- count = (p->current_frame == 0) ? p->preload_count : p->blocks_count_table[p->current_frame - 1];
+ count = (p->current_frame == 0) ? p->preload_count
+ : p->blocks_count_table[p->current_frame - 1];
for (i = 0; i < count; i++) {
if (p->current_frame_block >= p->frame_blks)
return AVERROR_INVALIDDATA;
@@ -245,7 +251,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->duration = 1;
memcpy(pkt->data, p->video_frame + p->frames_offset_table[p->current_frame], size);
if (pkt->data[0] & 0x20)
- pkt->flags |= AV_PKT_FLAG_KEY;
+ pkt->flags |= AV_PKT_FLAG_KEY;
p->current_frame++;
return pkt->size;