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.
Showing the changes to libavformat (1 of 1 file). Show all
Unified · Split
| @@ -444,15 +444,25 @@ static void ebml_writer_close_master(EbmlWriter *writer) · 443 unmodified lines | ||
| 444 | 444 | av_assert2(writer->current_master_element < writer->nb_elements); |
| 445 | 445 | elem = &writer->elements[writer->current_master_element]; |
| 446 | 446 | av_assert2(elem->type == EBML_MASTER); |
| 447 | + av_assert2(elem->priv.master.nb_elements < 0); /* means unset */ | |
| 447 | 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 | 451 | writer->current_master_element = elem->priv.master.containing_master; |
| 449 | 452 | } |
| 450 | 453 | |
| 451 | 454 | static void ebml_writer_close_or_discard_master(EbmlWriter *writer) |
| 452 | 455 | { |
| 453 | 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 | 459 | if (writer->current_master_element == writer->nb_elements - 1) { |
| 460 | + const EbmlElement *const elem = &writer->elements[writer->nb_elements - 1]; | |
| 455 | 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 | 466 | writer->nb_elements--; |
| 457 | 467 | return; |
| 458 | 468 | } |