[Ffmpeg-devel] [DRAFT] Add fact chunk to non-PCM wav
Michel Bardiaux
mbardiaux
Wed Feb 7 18:07:05 CET 2007
Michel Bardiaux wrote:
> Michael Niedermayer wrote:
>> Hi
>>
>> On Thu, Nov 09, 2006 at 01:53:08PM +0100, Michel Bardiaux wrote:
>>> Michael Niedermayer wrote:
>>>> Hi
>>>>
>>>> On Thu, Nov 09, 2006 at 11:36:13AM +0100, Michel Bardiaux wrote:
>>>>> Michael has reported that
>>>>>
>>>>>>> interresting, accoridng to microsofts excelent and unambigous
>>>>>>> documentation
>>>>>>> (not kidding ...)
>>>>>>> Fact Chunk
>>>>>>> This chunk is required for all WAVE formats other than
>>>>>>> WAVE_FORMAT_PCM. It stores file
>>>>>>> dependent information about the contents of the WAVE data. It
>>>>>>> currently specifies the time length of the
>>>>>>> data in samples.
>>>>>>>
>>>>>>> so this must not be under CODEC_ID_MSGSM, also it must be a
>>>>>>> seperate patch
>>>>>>> as its not CODEC_ID_MSGSM specific
>>>>> I took this literally, hence CODEC_ID_PCM_ALAW and
>>>>> CODEC_ID_PCM_MULAW will get a fact chunk too.
>>>> :)
>>>>
>>>> now just take the largest pts minus the smallest pts of any packet
>>>> stored
>>>> and convert that by using AVStream.time_base and
>>>> AVCodecContext.sample_rate
>>>> to the number of samples and store that in the fact chunk
>>> Right, the patch does not make sense without the final update of the
>>> chunk, and with a *general* formula, not the one I had specialised
>>> for MSGSM. I'm rather rusty on the handling of timestamps, so this
>>> might take some time
>>
>> in the write packet function
>> assert(avpacket->pts != AV_NOPTS_VALUE);
>> context->maxpts= FFMAX(context->maxpts, avpacket->pts);
>> context->minpts= FFMIN(context->minpts, avpacket->pts);
>>
>> and in write_trailer
>> number_of_sample= av_rescale(context->maxpts - context->minpts,
>> avctx->sample_rate * (int64_t)avstream->time_base.num,
>> avstream->time_base.den);
>>
>> untested of course but it should work approximately that way ...
>
> Thanks, it works, with a little correction: the duration of the last
> packet must be added to the difference in pts. I assumed the
> pkt->duration is in the same unit as the timestamps.
>
>>
>>>> then run the regression tests and send a patch which updates the
>>>> checksums
>>> Not clear how to proceed here, do you mean a subsequent patch, or in
>>> the same?
>
> I havent forgotten to make test, and of course the changes breaks
> regression since it adds 12 bytes to every non-PCM wav. I will post the
> final version with new checksums when the rest is approved.
>
Oops, forgot the attachment.
--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be
Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lavf_fact_1.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070207/3de2fb87/attachment.asc>
More information about the ffmpeg-devel
mailing list