[FFmpeg-devel] [PATCH] Core Audio Format demuxer (v2)
Michael Niedermayer
michaelni
Tue Aug 11 14:33:15 CEST 2009
On Mon, Aug 10, 2009 at 11:19:27PM +1000, Peter Ross wrote:
> On Sun, Aug 09, 2009 at 07:41:05PM +1000, Peter Ross wrote:
> > Enclosed is a revised version of Justin Ruggles CAF demuxer.
> >
> > Samples: http://samples.mplayerhq.hu/A-codecs/caf/
> > Original thread: http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-April/026491.html
>
> Revised patch enclosed.
>
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
> isom.h | 4 ++++
> mov.c | 35 ++++++++++++++++++++---------------
> 2 files changed, 24 insertions(+), 15 deletions(-)
> 542413cf2cd3ad4a0a49d44780f5b56012185462 0001-Make-mov-LPCM-and-AAC-parsing-functions-public-r2.patch
> From 8bf5aa9e5e24f86a5721c358fd30270cb8c3e39d Mon Sep 17 00:00:00 2001
> From: pross <pross at tablet.(none)>
> Date: Mon, 10 Aug 2009 21:15:50 +1000
> Subject: [PATCH] Make mov LPCM and AAC parsing functions public.
left to baptiste to review
[...]
> +static int probe(AVProbeData *p)
> +{
> + if (p->buf_size < 6)
> + return 0;
this check is unneeded, see AVPROBE_PADDING_SIZE
> + if (AV_RB32(p->buf) == MKBETAG('c','a','f','f') && AV_RB16(&p->buf[4]) == 1)
> + return AVPROBE_SCORE_MAX;
> + return 0;
> +}
> +
> +static int read_desc(AVFormatContext *s, int64_t size)
> +{
> + ByteIOContext *pb = s->pb;
> + CaffContext *caf = s->priv_data;
> + AVStream *st;
> + int flags;
> +
> + /* check chunk size */
> + if (size != 32)
> + return AVERROR_INVALIDDATA;
hmm, is there really a point to pass wsize if it has to be a specific
value anyway?
> +
> + /* new audio stream */
> + st = av_new_stream(s, 0);
> + if (!st)
> + return AVERROR_NOMEM;
> +
> + /* parse format description */
> + st->codec->codec_type = CODEC_TYPE_AUDIO;
> + st->codec->sample_rate = av_int2dbl(get_be64(pb));
> + st->codec->codec_tag = get_be32(pb);
> + flags = get_be32(pb);
> + caf->bytes_per_packet = get_be32(pb);
> + st->codec->block_align = caf->bytes_per_packet;
> + caf->frames_per_packet = get_be32(pb);
> + st->codec->channels = get_be32(pb);
> + st->codec->bits_per_coded_sample = get_be32(pb);
> +
> + /* calculate bit rate for constant size packets */
> + if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
> + st->codec->bit_rate = st->codec->sample_rate * caf->bytes_per_packet * 8;
> + st->codec->bit_rate /= caf->frames_per_packet;
st->codec->bit_rate = st->codec->sample_rate * caf->bytes_per_packet * 8
/ caf->frames_per_packet;
[...]
> +static int read_pakt(AVFormatContext *s, int64_t size)
> +{
> + ByteIOContext *pb = s->pb;
> + CaffContext *caf = s->priv_data;
> + int64_t bcount=0, fcount=0, ccount;
> + int i;
> +
> + ccount = url_ftell(pb);
> +
> + caf->num_packets = get_be64(pb);
> + if (caf->num_packets < 0 || (INT32_MAX/caf->num_packets) < sizeof(PacketTableEntry))
> + return AVERROR_INVALIDDATA;
id write INT32_MAX / sizeof(PacketTableEntry) < caf->num_packets
because the left side is a constant and known at compile time
> + caf->packet_table = av_mallocz(caf->num_packets * sizeof(PacketTableEntry));
> + if (!caf->packet_table)
> + return AVERROR_NOMEM;
> +
> + caf->has_packet_table = 1;
> + caf->num_frames = get_be64(pb); /* valid frames */
> + caf->num_frames += get_be32(pb); /* priming frames */
> + caf->num_frames += get_be32(pb); /* remainder frames */
> +
> + for(i=0; i<caf->num_packets; i++) {
> + if (!caf->bytes_per_packet)
> + caf->packet_table[i].bytes = ff_mp4_read_descr_len(pb);
> + else
if(){
}else
reduces future diff size
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090811/ec5ee5e0/attachment.pgp>
More information about the ffmpeg-devel
mailing list