[FFmpeg-devel] [PATCH 2/2] avformat/matroskaenc: Regression fix for invalid MKV headers

James Almer jamrial at gmail.com
Fri Jan 6 20:00:31 EET 2017


On 1/6/2017 2:41 PM, Soft Works wrote:
>> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of James Almer <jamrial at gmail.com>
>> Sent: Friday, January 6, 2017 6:02 AM
>>
>> IMO, no point calculating and writing a CRC element for this temporary state.
>> You can rename and simplify this function into something like
>>
>> static void end_ebml_master_preliminary(AVIOContext *pb, AVIOContext **dyn_cp,
>>                                         ebml_master master)
>> {
>>     uint8_t *buf;
>>     int size = avio_get_dyn_buf(*dyn_cp, &buf);
>>
>>     avio_write(pb, buf, size);
>>     end_ebml_master(pb, master);
>> }
> 
> James,
> 
> thanks for looking into this!
> 
> I wasn't sure if clients would be OK when some headers have CRC and some have not 
> (in the preliminary state). Also I'm not sure if clients are OK with the CRC bytes being 
> zero. 
> But if you're sure that all this is fine, I'll make this change...
> 
> softworkz

start_ebml_master_crc32() only reserves the space needed for the CRC32 element,
which is then written by end_ebml_master_crc32(). The preliminary header will
have a couple six bytes long Void elements that every parser will promptly
ignore.

CRC32 elements on this preliminarily state are pointless. Extra cycles wasted
calculating something that will be overwritten and recalculated at the end of
the process.



More information about the ffmpeg-devel mailing list