[FFmpeg-devel] [PATCH v2] Interpretation of duration field in AVI super index chunk

Michael Niedermayer michaelni at gmx.at
Wed Mar 4 00:26:56 CET 2015


On Tue, Mar 03, 2015 at 02:45:24PM +0100, Tobias Rapp wrote:
> On 26.02.2015 15:41, Michael Niedermayer wrote:
> >On Thu, Feb 26, 2015 at 02:14:33PM +0100, Tobias Rapp wrote:
> >>On 26.02.2015 00:51, Michael Niedermayer wrote:
> >>>On Wed, Feb 25, 2015 at 05:35:33PM +0100, Tobias Rapp wrote:
> [...]
> >>>>@@ -511,7 +514,11 @@ static int avi_write_ix(AVFormatContext *s)
> >>>>          avio_skip(pb, 16 * avi->riff_id);
> >>>>          avio_wl64(pb, ix);                    /* qwOffset */
> >>>>          avio_wl32(pb, pos - ix);              /* dwSize */
> >>>>-        avio_wl32(pb, avist->indexes.entry);  /* dwDuration */
> >>>>+        ff_parse_specific_params(s->streams[i], &au_byterate, &au_ssize, &au_scale);
> >>>>+        if (au_ssize == 0)
> >>>>+            avio_wl32(pb, avist->indexes.entry);  /* dwDuration (packet count) */
> >>>>+        else
> >>>
> >>>>+            avio_wl32(pb, (avist->audio_strm_length - avist->indexes.audio_strm_offset) / au_ssize);  /* dwDuration (sample count) */
> >>>
> >>>the rounding here is wrong
> >>>the index to be useable needs to have segments duration summable
> >>>as is this would lead to significangt errors if many of these
> >>>durations would be summed up
> >>>something like
> >>>avist->audio_strm_length / au_ssize - avist->indexes.audio_strm_offset / au_ssize
> >>>might avoid that but ive not tested it
> >>
> >>My assumption was that a stream packet contains only whole samples
> >>for linear/uncompressed audio (PCM) and that only for linear audio
> >>the expression "au_ssize > 0" evaluates to TRUE.
> >
> >We try to use au_ssize = 0 for compressed audio but i think it can be
> >non zero in some stream copy cases, iam not 100% sure though
> >
> >
> >>
> >>If that is not the case I can do the rounding as suggested or maybe
> >>introduce some separate stream duration counter based on
> >>AVPacket.duration?
> >
> >i think best to keep it simple and maybe print a request for a sample/
> >testcase if some combination of parameters is found which we are
> >unsure about if it works correctly
> >
> 
> Attached a new patch that calls avpriv_request_sample if the audio
> segment size is no multiple of au_ssize. Tested different audio
> encoder types (pcm_s16le, pcm_s24le, adpcm_ms, mp2, libmp3lame) with
> success.
> 
> Regards,
> Tobias

>  avienc.c |   15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 18613900301b05e351e2a1a5009e9f5801c20ffc  0001-libavformat-avienc-Fix-duration-of-audio-segment-in-.patch
> From 89d3f13169e2ff183a1e60c9939263035ad83a0f Mon Sep 17 00:00:00 2001
> From: Tobias Rapp <t.rapp at noa-audio.com>
> Date: Tue, 3 Mar 2015 13:29:05 +0100
> Subject: [PATCH] libavformat/avienc: Fix duration of audio segment in OpenDML
>  master index

applied

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150304/b103d0b3/attachment.asc>


More information about the ffmpeg-devel mailing list