History

avformat/matroskaenc: Reset cur_master_element when discarding master

Before this patch the muxer writes an invalid file (namely one in which the Projection master is a child of the Colour element) if the following conditions are met: a) The stream contains AVMasteringDisplayMetadata without primaries and luminance (i.e. useless AVMasteringDisplayMetadata). b) The stream contains AV_PKT_DATA_SPHERICAL side data. c) All the colour elements of the stream are equal to default (i.e. unknown). Fortunately these conditions are very unlikely to be met.

Andreas Rheinhardt committed 4 years ago

Commit 49a63c61 parent 9ff0fbb1 file · +10 −0Browse files

Unified · Split

libavformat/matroskaenc.c+10−0
@@ -444,15 +444,25 @@ static void ebml_writer_close_master(EbmlWriter *writer) · 443 unmodified lines
444 av_assert2(writer->current_master_element < writer->nb_elements);444 av_assert2(writer->current_master_element < writer->nb_elements);
445 elem = &writer->elements[writer->current_master_element];445 elem = &writer->elements[writer->current_master_element];
446 av_assert2(elem->type == EBML_MASTER);446 av_assert2(elem->type == EBML_MASTER);
447 av_assert2(elem->priv.master.nb_elements < 0); /* means unset */
447 elem->priv.master.nb_elements = writer->nb_elements - writer->current_master_element - 1;448 elem->priv.master.nb_elements = writer->nb_elements - writer->current_master_element - 1;
449 av_assert2(elem->priv.master.containing_master < 0 ||
450 elem->priv.master.containing_master < writer->current_master_element);
448 writer->current_master_element = elem->priv.master.containing_master;451 writer->current_master_element = elem->priv.master.containing_master;
449}452}
450 453
451static void ebml_writer_close_or_discard_master(EbmlWriter *writer)454static void ebml_writer_close_or_discard_master(EbmlWriter *writer)
452{455{
453 av_assert2(writer->nb_elements > 0);456 av_assert2(writer->nb_elements > 0);
457 av_assert2(0 <= writer->current_master_element);
458 av_assert2(writer->current_master_element < writer->nb_elements);
454 if (writer->current_master_element == writer->nb_elements - 1) {459 if (writer->current_master_element == writer->nb_elements - 1) {
460 const EbmlElement *const elem = &writer->elements[writer->nb_elements - 1];
455 /* The master element has no children. Discard it. */461 /* The master element has no children. Discard it. */
462 av_assert2(elem->type == EBML_MASTER);
463 av_assert2(elem->priv.master.containing_master < 0 ||
464 elem->priv.master.containing_master < writer->current_master_element);
465 writer->current_master_element = elem->priv.master.containing_master;
456 writer->nb_elements--;466 writer->nb_elements--;
457 return;467 return;
458 }468 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t