[Ffmpeg-devel] [PATCH] WAVE and AIFF packets timestamps
Michael Niedermayer
michaelni
Tue Sep 5 17:38:55 CEST 2006
Hi
On Tue, Sep 05, 2006 at 08:06:25AM -0400, Patrick Guimond wrote:
> Hi
>
> This patch sets the pts and duration fields of WAVE and AIFF packets
> when decoding raw pcm.
>
> Greetings,
> Patrick Guimond
>
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c (revision 6173)
> +++ libavformat/raw.c (working copy)
> @@ -218,6 +218,33 @@
> return 0;
> }
>
> +/**
> + * set timestamp/duration info for the packet, based on the stream info
> + * and byte position of the packet
> + *
> + * @param pkt packet
> + * @param format context of the packet
> + * @param st_start_pos stream start position, in bytes
> + */
> +void pcm_pkt_set_ts(AVPacket *pkt, AVStream *st, int64_t st_start_pos)
> +{
> + /* Div by 0 check */
> + if (!st->codec->block_align)
> + return;
> +
> + /* Setting only if not already known */
> + if (pkt->pts == AV_NOPTS_VALUE) {
> + if (pkt->pos < st_start_pos)
this should be assert(pkt->pos >= st_start_pos) as the pakets before the
start_pos really doesnt seem valid ...
also id tend to put this in utils.c rather then raw.c and add a av_ instead
of pcm_ prefix maybe call it av_cbr_set_ts()
[...]
> Index: libavformat/aiff.c
> ===================================================================
> --- libavformat/aiff.c (revision 6173)
> +++ libavformat/aiff.c (working copy)
> @@ -40,6 +40,13 @@
> #define AIFF 0
> #define AIFF_C_VERSION1 0xA2805140
>
> +typedef struct {
> + offset_t form;
> + offset_t frames;
> + offset_t ssnd;
> + offset_t data;
> +} AIFFContext;
> +
> static int aiff_codec_get_id (int bps)
> {
> if (bps <= 8)
> @@ -118,10 +125,8 @@
> double sample_rate;
> unsigned int num_frames;
>
> + size += size & 1;
>
> - if (size & 1)
> - size++;
well, this definitly doesnt belong in this patch and for a seperate patch its
probably too irrelevant ...
> -
> codec->codec_type = CODEC_TYPE_AUDIO;
> codec->channels = get_be16(pb);
> num_frames = get_be32(pb);
> @@ -166,15 +171,9 @@
> }
>
> #ifdef CONFIG_MUXERS
> -typedef struct {
> - offset_t form;
> - offset_t frames;
> - offset_t ssnd;
> -} AIFFOutputContext;
> -
this is mostly cosmetic and rejected, this can be done with far fewer
changed lines
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the ffmpeg-devel
mailing list