Lines Matching refs:cpl
169 static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl)
177 cpl->content_title_utf8 = xmlNodeListGetString(cpl_element->doc,
180 if (!cpl->content_title_utf8)
181 cpl->content_title_utf8 = xmlStrdup("");
182 if (!cpl->content_title_utf8)
188 static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl)
197 return ff_imf_xml_read_rational(element, &cpl->edit_rate);
200 static int fill_id(xmlNodePtr cpl_element, FFIMFCPL *cpl)
209 return ff_imf_xml_read_uuid(element, cpl->id_uuid);
246 static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resource, FFIMFCPL *cpl)
253 resource->edit_rate = cpl->edit_rate;
297 FFIMFCPL *cpl)
302 if ((ret = fill_base_resource(tf_resource_elem, (FFIMFBaseResource *)tf_resource, cpl)))
321 FFIMFCPL *cpl)
326 if ((ret = fill_base_resource(marker_resource_elem, (FFIMFBaseResource *)marker_resource, cpl)))
358 static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
383 if (!cpl->main_markers_track) {
384 cpl->main_markers_track = av_malloc(sizeof(FFIMFMarkerVirtualTrack));
385 if (!cpl->main_markers_track)
387 imf_marker_virtual_track_init(cpl->main_markers_track);
388 av_uuid_copy(cpl->main_markers_track->base.id_uuid, uuid);
390 } else if (!av_uuid_equal(cpl->main_markers_track->base.id_uuid, uuid)) {
402 || cpl->main_markers_track->resource_count > UINT32_MAX - resource_elem_count)
404 tmp = av_realloc_array(cpl->main_markers_track->resources,
405 cpl->main_markers_track->resource_count + resource_elem_count,
411 cpl->main_markers_track->resources = tmp;
415 imf_marker_resource_init(&cpl->main_markers_track->resources[cpl->main_markers_track->resource_count]);
417 &cpl->main_markers_track->resources[cpl->main_markers_track->resource_count],
418 cpl);
419 cpl->main_markers_track->resource_count++;
445 static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cpl)
471 for (uint32_t i = 0; i < cpl->main_audio_track_count; i++) {
472 if (av_uuid_equal(cpl->main_audio_tracks[i].base.id_uuid, uuid)) {
473 vt = &cpl->main_audio_tracks[i];
480 if (cpl->main_audio_track_count == UINT32_MAX)
482 tmp = av_realloc_array(cpl->main_audio_tracks,
483 cpl->main_audio_track_count + 1,
488 cpl->main_audio_tracks = tmp;
489 vt = &cpl->main_audio_tracks[cpl->main_audio_track_count];
491 cpl->main_audio_track_count++;
519 cpl);
531 static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL *cpl)
558 if (!cpl->main_image_2d_track) {
559 cpl->main_image_2d_track = av_malloc(sizeof(FFIMFTrackFileVirtualTrack));
560 if (!cpl->main_image_2d_track)
562 imf_trackfile_virtual_track_init(cpl->main_image_2d_track);
563 av_uuid_copy(cpl->main_image_2d_track->base.id_uuid, uuid);
565 } else if (!av_uuid_equal(cpl->main_image_2d_track->base.id_uuid, uuid)) {
581 || cpl->main_image_2d_track->resource_count > UINT32_MAX - resource_elem_count
582 || (cpl->main_image_2d_track->resource_count + resource_elem_count)
585 tmp = av_fast_realloc(cpl->main_image_2d_track->resources,
586 &cpl->main_image_2d_track->resources_alloc_sz,
587 (cpl->main_image_2d_track->resource_count + resource_elem_count)
593 cpl->main_image_2d_track->resources = tmp;
598 &cpl->main_image_2d_track->resources[cpl->main_image_2d_track->resource_count]);
600 &cpl->main_image_2d_track->resources[cpl->main_image_2d_track->resource_count],
601 cpl);
605 cpl->main_image_2d_track->resource_count++;
613 static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl)
638 ret = push_marker_sequence(sequence_elem, cpl);
641 ret = push_main_image_2d_sequence(sequence_elem, cpl);
644 ret = push_main_audio_sequence(sequence_elem, cpl);
665 int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl)
670 *cpl = ff_imf_cpl_alloc();
671 if (!*cpl) {
683 if ((ret = fill_content_title(cpl_element, *cpl)))
685 if ((ret = fill_id(cpl_element, *cpl)))
687 if ((ret = fill_edit_rate(cpl_element, *cpl)))
689 if ((ret = fill_virtual_tracks(cpl_element, *cpl)))
693 if (*cpl && ret) {
694 ff_imf_cpl_free(*cpl);
695 *cpl = NULL;
733 static void imf_cpl_init(FFIMFCPL *cpl)
735 av_uuid_nil(cpl->id_uuid);
736 cpl->content_title_utf8 = NULL;
737 cpl->edit_rate = av_make_q(0, 1);
738 cpl->main_markers_track = NULL;
739 cpl->main_image_2d_track = NULL;
740 cpl->main_audio_track_count = 0;
741 cpl->main_audio_tracks = NULL;
746 FFIMFCPL *cpl;
748 cpl = av_malloc(sizeof(FFIMFCPL));
749 if (!cpl)
751 imf_cpl_init(cpl);
752 return cpl;
755 void ff_imf_cpl_free(FFIMFCPL *cpl)
757 if (!cpl)
760 xmlFree(cpl->content_title_utf8);
762 imf_marker_virtual_track_free(cpl->main_markers_track);
764 if (cpl->main_markers_track)
765 av_freep(&cpl->main_markers_track);
767 imf_trackfile_virtual_track_free(cpl->main_image_2d_track);
769 if (cpl->main_image_2d_track)
770 av_freep(&cpl->main_image_2d_track);
772 for (uint32_t i = 0; i < cpl->main_audio_track_count; i++)
773 imf_trackfile_virtual_track_free(&cpl->main_audio_tracks[i]);
775 if (cpl->main_audio_tracks)
776 av_freep(&cpl->main_audio_tracks);
778 av_freep(&cpl);
781 int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl)
808 if ((ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl))) {
814 (*cpl)->content_title_utf8);
818 AV_UUID_ARG((*cpl)->id_uuid));