History

avformat/imf: clean-up logging * remove logging to NULL * remove extraneous logging

Pierre-Anthony Lemieux committed 3 years ago

Commit 0f2f0dd1 parent ba2c7914 files · +91 −100Browse files

Unified · Split

4 files
  1. libavformat/imf.h +4 −2
  2. libavformat/imf_cpl.c +84 −95
  3. libavformat/imfdec.c +1 −1
  4. libavformat/tests/imf.c +2 −2
libavformat/imf.h+4−2
@@ -140,6 +140,7 @@ typedef struct FFIMFCPL { · 139 unmodified lines
140140
141141 /**
142142 * Parse an IMF CompositionPlaylist element into the FFIMFCPL data structure.
143+ * @param[in] log_ctx Logging context (points to an instance of AVClass). May be NULL.
143144 * @param[in] doc An XML document from which the CPL is read.
144145 * @param[out] cpl Pointer to a memory area (allocated by the client), where the
145146 * function writes a pointer to the newly constructed FFIMFCPL structure (or
@@ -147,10 +148,11 @@ typedef struct FFIMFCPL { · 1 unmodified line
147148 * the FFIMFCPL structure using ff_imf_cpl_free().
148149 * @return A non-zero value in case of an error.
149150 */
150−int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl);
151+int ff_imf_parse_cpl_from_xml_dom(void *log_ctx, xmlDocPtr doc, FFIMFCPL **cpl);
151152
152153 /**
153154 * Parse an IMF Composition Playlist document into the FFIMFCPL data structure.
155+ * @param[in] log_ctx Logging context (points to an instance of AVClass). May be NULL.
154156 * @param[in] in The context from which the CPL is read.
155157 * @param[out] cpl Pointer to a memory area (allocated by the client), where the
156158 * function writes a pointer to the newly constructed FFIMFCPL structure (or
@@ -158,7 +160,7 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl); · 1 unmodified line
158160 * the FFIMFCPL structure using ff_imf_cpl_free().
159161 * @return A non-zero value in case of an error.
160162 */
161−int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl);
163+int ff_imf_parse_cpl(void *log_ctx, AVIOContext *in, FFIMFCPL **cpl);
162164
163165 /**
164166 * Allocates and initializes an FFIMFCPL data structure.
libavformat/imf_cpl.c+84−95
@@ -76,10 +76,8 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) · 75 unmodified lines
7676
7777 xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
7878 ret = av_uuid_urn_parse(element_text, uuid);
79− if (ret) {
80− av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n");
79+ if (ret)
8180 ret = AVERROR_INVALIDDATA;
82− }
8381 xmlFree(element_text);
8482
8583 return ret;
@@ -90,10 +88,8 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) · 4 unmodified lines
9088 int ret = 0;
9189
9290 xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
93− if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) {
94− av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n");
91+ if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2)
9592 ret = AVERROR_INVALIDDATA;
96− }
9793 xmlFree(element_text);
9894
9995 return ret;
@@ -104,10 +100,8 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) · 4 unmodified lines
104100 int ret = 0;
105101
106102 xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
107− if (sscanf(element_text, "%" PRIu32, number) != 1) {
108− av_log(NULL, AV_LOG_ERROR, "Invalid unsigned 32-bit integer");
103+ if (sscanf(element_text, "%" PRIu32, number) != 1)
109104 ret = AVERROR_INVALIDDATA;
110− }
111105 xmlFree(element_text);
112106
113107 return ret;
@@ -181,10 +175,8 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 67 unmodified lines
181175 {
182176 xmlNodePtr element = NULL;
183177
184− if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "ContentTitle"))) {
185− av_log(NULL, AV_LOG_ERROR, "ContentTitle element not found in the IMF CPL\n");
178+ if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "ContentTitle")))
186179 return AVERROR_INVALIDDATA;
187− }
188180 cpl->content_title_utf8 = xmlNodeListGetString(cpl_element->doc,
189181 element->xmlChildrenNode,
190182 1);
@@ -242,22 +234,15 @@ static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 51 unmodified lines
242234 return 0;
243235
244236 element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeDropFrame");
245− if (!element) {
246− av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
247− a TimecodeDropFrame child element\n");
237+ if (!element)
248238 return AVERROR_INVALIDDATA;
249− }
250239
251− if (ff_imf_xml_read_boolean(element, &df)) {
252− av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n");
240+ if (ff_imf_xml_read_boolean(element, &df))
253241 return AVERROR_INVALIDDATA;
254− }
242+
255243 element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeStartAddress");
256− if (!element) {
257− av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\
258− a TimecodeStartAddress child element\n");
244+ if (!element)
259245 return AVERROR_INVALIDDATA;
260− }
261246
262247 tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1);
263248 ret = parse_cpl_tc_type(tc_str, comps);
@@ -280,10 +265,8 @@ static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 16 unmodified lines
280265 {
281266 xmlNodePtr element = NULL;
282267
283− if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "EditRate"))) {
284− av_log(NULL, AV_LOG_ERROR, "EditRate element not found in the IMF CPL\n");
268+ if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "EditRate")))
285269 return AVERROR_INVALIDDATA;
286− }
287270
288271 return ff_imf_xml_read_rational(element, &cpl->edit_rate);
289272 }
@@ -292,10 +275,8 @@ static int fill_id(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines
292275 {
293276 xmlNodePtr element = NULL;
294277
295− if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "Id"))) {
296− av_log(NULL, AV_LOG_ERROR, "Id element not found in the IMF CPL\n");
278+ if (!(element = ff_imf_xml_get_child_element_by_name(cpl_element, "Id")))
297279 return AVERROR_INVALIDDATA;
298− }
299280
300281 return ff_imf_xml_read_uuid(element, cpl->id_uuid);
301282 }
@@ -306,22 +287,19 @@ static int fill_marker(xmlNodePtr marker_elem, FFIMFMarker *marker) · 4 unmodified lines
306287 int ret = 0;
307288
308289 /* read Offset */
309− if (!(element = ff_imf_xml_get_child_element_by_name(marker_elem, "Offset"))) {
310− av_log(NULL, AV_LOG_ERROR, "Offset element not found in a Marker\n");
290+ if (!(element = ff_imf_xml_get_child_element_by_name(marker_elem, "Offset")))
311291 return AVERROR_INVALIDDATA;
312− }
292+
313293 if ((ret = ff_imf_xml_read_uint32(element, &marker->offset)))
314294 return ret;
315295
316296 /* read Label and Scope */
317− if (!(element = ff_imf_xml_get_child_element_by_name(marker_elem, "Label"))) {
318− av_log(NULL, AV_LOG_ERROR, "Label element not found in a Marker\n");
297+ if (!(element = ff_imf_xml_get_child_element_by_name(marker_elem, "Label")))
319298 return AVERROR_INVALIDDATA;
320− }
321− if (!(marker->label_utf8 = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1))) {
322− av_log(NULL, AV_LOG_ERROR, "Empty Label element found in a Marker\n");
299+
300+ if (!(marker->label_utf8 = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1)))
323301 return AVERROR_INVALIDDATA;
324− }
302+
325303 if (!(marker->scope_utf8 = xmlGetNoNsProp(element, "scope"))) {
326304 marker->scope_utf8
327305 = xmlCharStrdup("http://www.smpte-ra.org/schemas/2067-3/2013#standard-markers");
@@ -334,7 +312,8 @@ static int fill_marker(xmlNodePtr marker_elem, FFIMFMarker *marker) · 6 unmodified lines
334312 return ret;
335313 }
336314
337−static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resource, FFIMFCPL *cpl)
315+static int fill_base_resource(void *log_ctx, xmlNodePtr resource_elem,
316+ FFIMFBaseResource *resource, FFIMFCPL *cpl)
338317 {
339318 xmlNodePtr element = NULL;
340319 int ret = 0;
@@ -343,14 +322,14 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 2 unmodified lines
343322 if (!(element = ff_imf_xml_get_child_element_by_name(resource_elem, "EditRate"))) {
344323 resource->edit_rate = cpl->edit_rate;
345324 } else if ((ret = ff_imf_xml_read_rational(element, &resource->edit_rate))) {
346− av_log(NULL, AV_LOG_ERROR, "Invalid EditRate element found in a Resource\n");
325+ av_log(log_ctx, AV_LOG_ERROR, "Invalid EditRate element found in a Resource\n");
347326 return ret;
348327 }
349328
350329 /* read EntryPoint */
351330 if ((element = ff_imf_xml_get_child_element_by_name(resource_elem, "EntryPoint"))) {
352331 if ((ret = ff_imf_xml_read_uint32(element, &resource->entry_point))) {
353− av_log(NULL, AV_LOG_ERROR, "Invalid EntryPoint element found in a Resource\n");
332+ av_log(log_ctx, AV_LOG_ERROR, "Invalid EntryPoint element found in a Resource\n");
354333 return ret;
355334 }
356335 } else {
@@ -359,11 +338,11 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 2 unmodified lines
359338
360339 /* read IntrinsicDuration */
361340 if (!(element = ff_imf_xml_get_child_element_by_name(resource_elem, "IntrinsicDuration"))) {
362− av_log(NULL, AV_LOG_ERROR, "IntrinsicDuration element missing from Resource\n");
341+ av_log(log_ctx, AV_LOG_ERROR, "IntrinsicDuration element missing from Resource\n");
363342 return AVERROR_INVALIDDATA;
364343 }
365344 if ((ret = ff_imf_xml_read_uint32(element, &resource->duration))) {
366− av_log(NULL, AV_LOG_ERROR, "Invalid IntrinsicDuration element found in a Resource\n");
345+ av_log(log_ctx, AV_LOG_ERROR, "Invalid IntrinsicDuration element found in a Resource\n");
367346 return ret;
368347 }
369348 resource->duration -= resource->entry_point;
@@ -371,7 +350,7 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 1 unmodified line
371350 /* read SourceDuration */
372351 if ((element = ff_imf_xml_get_child_element_by_name(resource_elem, "SourceDuration"))) {
373352 if ((ret = ff_imf_xml_read_uint32(element, &resource->duration))) {
374− av_log(NULL, AV_LOG_ERROR, "SourceDuration element missing from Resource\n");
353+ av_log(log_ctx, AV_LOG_ERROR, "SourceDuration element missing from Resource\n");
375354 return ret;
376355 }
377356 }
@@ -383,38 +362,38 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 5 unmodified lines
383362 return ret;
384363 }
385364
386−static int fill_trackfile_resource(xmlNodePtr tf_resource_elem,
365+static int fill_trackfile_resource(void *log_ctx, xmlNodePtr tf_resource_elem,
387366 FFIMFTrackFileResource *tf_resource,
388367 FFIMFCPL *cpl)
389368 {
390369 xmlNodePtr element = NULL;
391370 int ret = 0;
392371
393− if ((ret = fill_base_resource(tf_resource_elem, (FFIMFBaseResource *)tf_resource, cpl)))
372+ if ((ret = fill_base_resource(log_ctx, tf_resource_elem, (FFIMFBaseResource *)tf_resource, cpl)))
394373 return ret;
395374
396375 /* read TrackFileId */
397376 if ((element = ff_imf_xml_get_child_element_by_name(tf_resource_elem, "TrackFileId"))) {
398377 if ((ret = ff_imf_xml_read_uuid(element, tf_resource->track_file_uuid))) {
399− av_log(NULL, AV_LOG_ERROR, "Invalid TrackFileId element found in Resource\n");
378+ av_log(log_ctx, AV_LOG_ERROR, "Invalid TrackFileId element found in Resource\n");
400379 return ret;
401380 }
402381 } else {
403− av_log(NULL, AV_LOG_ERROR, "TrackFileId element missing from Resource\n");
382+ av_log(log_ctx, AV_LOG_ERROR, "TrackFileId element missing from Resource\n");
404383 return AVERROR_INVALIDDATA;
405384 }
406385
407386 return ret;
408387 }
409388
410−static int fill_marker_resource(xmlNodePtr marker_resource_elem,
389+static int fill_marker_resource(void *log_ctx, xmlNodePtr marker_resource_elem,
411390 FFIMFMarkerResource *marker_resource,
412391 FFIMFCPL *cpl)
413392 {
414393 xmlNodePtr element = NULL;
415394 int ret = 0;
416395
417− if ((ret = fill_base_resource(marker_resource_elem, (FFIMFBaseResource *)marker_resource, cpl)))
396+ if ((ret = fill_base_resource(log_ctx, marker_resource_elem, (FFIMFBaseResource *)marker_resource, cpl)))
418397 return ret;
419398
420399 /* read markers */
@@ -436,8 +415,10 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem, · 15 unmodified lines
436415 ret = fill_marker(element,
437416 &marker_resource->markers[marker_resource->marker_count]);
438417 marker_resource->marker_count++;
439− if (ret)
418+ if (ret) {
419+ av_log(log_ctx, AV_LOG_ERROR, "Invalid Marker element\n");
440420 return ret;
421+ }
441422 }
442423
443424 element = xmlNextElementSibling(element);
@@ -446,7 +427,7 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem, · 2 unmodified lines
446427 return ret;
447428 }
448429
449−static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
430+static int push_marker_sequence(void *log_ctx, xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl)
450431 {
451432 int ret = 0;
452433 AVUUID uuid;
@@ -458,14 +439,14 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 5 unmodified lines
458439
459440 /* read TrackID element */
460441 if (!(track_id_elem = ff_imf_xml_get_child_element_by_name(marker_sequence_elem, "TrackId"))) {
461− av_log(NULL, AV_LOG_ERROR, "TrackId element missing from Sequence\n");
442+ av_log(log_ctx, AV_LOG_ERROR, "TrackId element missing from Sequence\n");
462443 return AVERROR_INVALIDDATA;
463444 }
464445 if (ff_imf_xml_read_uuid(track_id_elem, uuid)) {
465− av_log(NULL, AV_LOG_ERROR, "Invalid TrackId element found in Sequence\n");
446+ av_log(log_ctx, AV_LOG_ERROR, "Invalid TrackId element found in Sequence\n");
466447 return AVERROR_INVALIDDATA;
467448 }
468− av_log(NULL,
449+ av_log(log_ctx,
469450 AV_LOG_DEBUG,
470451 "Processing IMF CPL Marker Sequence for Virtual Track " AV_PRI_UUID "\n",
471452 AV_UUID_ARG(uuid));
@@ -479,7 +460,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 7 unmodified lines
479460 av_uuid_copy(cpl->main_markers_track->base.id_uuid, uuid);
480461
481462 } else if (!av_uuid_equal(cpl->main_markers_track->base.id_uuid, uuid)) {
482− av_log(NULL, AV_LOG_ERROR, "Multiple marker virtual tracks were found\n");
463+ av_log(log_ctx, AV_LOG_ERROR, "Multiple marker virtual tracks were found\n");
483464 return AVERROR_INVALIDDATA;
484465 }
485466
@@ -496,7 +477,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 10 unmodified lines
496477 cpl->main_markers_track->resource_count + resource_elem_count,
497478 sizeof(FFIMFMarkerResource));
498479 if (!tmp) {
499− av_log(NULL, AV_LOG_ERROR, "Cannot allocate Marker Resources\n");
480+ av_log(log_ctx, AV_LOG_ERROR, "Cannot allocate Marker Resources\n");
500481 return AVERROR(ENOMEM);
501482 }
502483 cpl->main_markers_track->resources = tmp;
@@ -504,7 +485,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 1 unmodified line
504485 resource_elem = xmlFirstElementChild(resource_list_elem);
505486 while (resource_elem) {
506487 imf_marker_resource_init(&cpl->main_markers_track->resources[cpl->main_markers_track->resource_count]);
507− ret = fill_marker_resource(resource_elem,
488+ ret = fill_marker_resource(log_ctx, resource_elem,
508489 &cpl->main_markers_track->resources[cpl->main_markers_track->resource_count],
509490 cpl);
510491 cpl->main_markers_track->resource_count++;
@@ -533,7 +514,7 @@ static int has_stereo_resources(xmlNodePtr element) · 22 unmodified lines
533514 return 0;
534515 }
535516
536−static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cpl)
517+static int push_main_audio_sequence(void *log_ctx, xmlNodePtr audio_sequence_elem, FFIMFCPL *cpl)
537518 {
538519 int ret = 0;
539520 AVUUID uuid;
@@ -546,14 +527,14 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 6 unmodified lines
546527
547528 /* read TrackID element */
548529 if (!(track_id_elem = ff_imf_xml_get_child_element_by_name(audio_sequence_elem, "TrackId"))) {
549− av_log(NULL, AV_LOG_ERROR, "TrackId element missing from audio sequence\n");
530+ av_log(log_ctx, AV_LOG_ERROR, "TrackId element missing from audio sequence\n");
550531 return AVERROR_INVALIDDATA;
551532 }
552533 if ((ret = ff_imf_xml_read_uuid(track_id_elem, uuid))) {
553− av_log(NULL, AV_LOG_ERROR, "Invalid TrackId element found in audio sequence\n");
534+ av_log(log_ctx, AV_LOG_ERROR, "Invalid TrackId element found in audio sequence\n");
554535 return ret;
555536 }
556− av_log(NULL,
537+ av_log(log_ctx,
557538 AV_LOG_DEBUG,
558539 "Processing IMF CPL Audio Sequence for Virtual Track " AV_PRI_UUID "\n",
559540 AV_UUID_ARG(uuid));
@@ -597,7 +578,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 37 unmodified lines
597578 (vt->resource_count + resource_elem_count)
598579 * sizeof(FFIMFTrackFileResource));
599580 if (!tmp) {
600− av_log(NULL, AV_LOG_ERROR, "Cannot allocate Main Audio Resources\n");
581+ av_log(log_ctx, AV_LOG_ERROR, "Cannot allocate Main Audio Resources\n");
601582 return AVERROR(ENOMEM);
602583 }
603584 vt->resources = tmp;
@@ -605,11 +586,11 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 1 unmodified line
605586 resource_elem = xmlFirstElementChild(resource_list_elem);
606587 while (resource_elem) {
607588 imf_trackfile_resource_init(&vt->resources[vt->resource_count]);
608− ret = fill_trackfile_resource(resource_elem,
589+ ret = fill_trackfile_resource(log_ctx, resource_elem,
609590 &vt->resources[vt->resource_count],
610591 cpl);
611592 if (ret)
612− av_log(NULL, AV_LOG_ERROR, "Invalid Resource\n");
593+ av_log(log_ctx, AV_LOG_ERROR, "Invalid Resource\n");
613594 else
614595 vt->resource_count++;
615596
@@ -619,7 +600,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 3 unmodified lines
619600 return ret;
620601 }
621602
622−static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL *cpl)
603+static int push_main_image_2d_sequence(void *log_ctx, xmlNodePtr image_sequence_elem, FFIMFCPL *cpl)
623604 {
624605 int ret = 0;
625606 AVUUID uuid;
@@ -631,17 +612,17 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 5 unmodified lines
631612
632613 /* skip stereoscopic resources */
633614 if (has_stereo_resources(image_sequence_elem)) {
634− av_log(NULL, AV_LOG_ERROR, "Stereoscopic 3D image virtual tracks not supported\n");
615+ av_log(log_ctx, AV_LOG_ERROR, "Stereoscopic 3D image virtual tracks not supported\n");
635616 return AVERROR_PATCHWELCOME;
636617 }
637618
638619 /* read TrackId element*/
639620 if (!(track_id_elem = ff_imf_xml_get_child_element_by_name(image_sequence_elem, "TrackId"))) {
640− av_log(NULL, AV_LOG_ERROR, "TrackId element missing from audio sequence\n");
621+ av_log(log_ctx, AV_LOG_ERROR, "TrackId element missing from audio sequence\n");
641622 return AVERROR_INVALIDDATA;
642623 }
643624 if ((ret = ff_imf_xml_read_uuid(track_id_elem, uuid))) {
644− av_log(NULL, AV_LOG_ERROR, "Invalid TrackId element found in audio sequence\n");
625+ av_log(log_ctx, AV_LOG_ERROR, "Invalid TrackId element found in audio sequence\n");
645626 return ret;
646627 }
647628
@@ -654,10 +635,10 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 6 unmodified lines
654635 av_uuid_copy(cpl->main_image_2d_track->base.id_uuid, uuid);
655636
656637 } else if (!av_uuid_equal(cpl->main_image_2d_track->base.id_uuid, uuid)) {
657− av_log(NULL, AV_LOG_ERROR, "Multiple MainImage virtual tracks found\n");
638+ av_log(log_ctx, AV_LOG_ERROR, "Multiple MainImage virtual tracks found\n");
658639 return AVERROR_INVALIDDATA;
659640 }
660− av_log(NULL,
641+ av_log(log_ctx,
661642 AV_LOG_DEBUG,
662643 "Processing IMF CPL Main Image Sequence for Virtual Track " AV_PRI_UUID "\n",
663644 AV_UUID_ARG(uuid));
@@ -678,7 +659,7 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 14 unmodified lines
678659 (cpl->main_image_2d_track->resource_count + resource_elem_count)
679660 * sizeof(FFIMFTrackFileResource));
680661 if (!tmp) {
681− av_log(NULL, AV_LOG_ERROR, "Cannot allocate Main Image Resources\n");
662+ av_log(log_ctx, AV_LOG_ERROR, "Cannot allocate Main Image Resources\n");
682663 return AVERROR(ENOMEM);
683664 }
684665 cpl->main_image_2d_track->resources = tmp;
@@ -687,11 +668,11 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 2 unmodified lines
687668 while (resource_elem) {
688669 imf_trackfile_resource_init(
689670 &cpl->main_image_2d_track->resources[cpl->main_image_2d_track->resource_count]);
690− ret = fill_trackfile_resource(resource_elem,
671+ ret = fill_trackfile_resource(log_ctx, resource_elem,
691672 &cpl->main_image_2d_track->resources[cpl->main_image_2d_track->resource_count],
692673 cpl);
693674 if (ret)
694− av_log(NULL, AV_LOG_ERROR, "Invalid Resource\n");
675+ av_log(log_ctx, AV_LOG_ERROR, "Invalid Resource\n");
695676 else
696677 cpl->main_image_2d_track->resource_count++;
697678
@@ -701,7 +682,7 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 3 unmodified lines
701682 return 0;
702683 }
703684
704−static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl)
685+static int fill_virtual_tracks(void *log_ctx, xmlNodePtr cpl_element, FFIMFCPL *cpl)
705686 {
706687 int ret = 0;
707688 xmlNodePtr segment_list_elem = NULL;
@@ -710,14 +691,14 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines
710691 xmlNodePtr sequence_elem = NULL;
711692
712693 if (!(segment_list_elem = ff_imf_xml_get_child_element_by_name(cpl_element, "SegmentList"))) {
713− av_log(NULL, AV_LOG_ERROR, "SegmentList element missing\n");
694+ av_log(log_ctx, AV_LOG_ERROR, "SegmentList element missing\n");
714695 return AVERROR_INVALIDDATA;
715696 }
716697
717698 /* process sequences */
718699 segment_elem = xmlFirstElementChild(segment_list_elem);
719700 while (segment_elem) {
720− av_log(NULL, AV_LOG_DEBUG, "Processing IMF CPL Segment\n");
701+ av_log(log_ctx, AV_LOG_DEBUG, "Processing IMF CPL Segment\n");
721702
722703 sequence_list_elem = ff_imf_xml_get_child_element_by_name(segment_elem, "SequenceList");
723704 if (!sequence_list_elem)
@@ -726,16 +707,16 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines
726707 sequence_elem = xmlFirstElementChild(sequence_list_elem);
727708 while (sequence_elem) {
728709 if (xmlStrcmp(sequence_elem->name, "MarkerSequence") == 0)
729− ret = push_marker_sequence(sequence_elem, cpl);
710+ ret = push_marker_sequence(log_ctx, sequence_elem, cpl);
730711
731712 else if (xmlStrcmp(sequence_elem->name, "MainImageSequence") == 0)
732− ret = push_main_image_2d_sequence(sequence_elem, cpl);
713+ ret = push_main_image_2d_sequence(log_ctx, sequence_elem, cpl);
733714
734715 else if (xmlStrcmp(sequence_elem->name, "MainAudioSequence") == 0)
735− ret = push_main_audio_sequence(sequence_elem, cpl);
716+ ret = push_main_audio_sequence(log_ctx, sequence_elem, cpl);
736717
737718 else
738− av_log(NULL,
719+ av_log(log_ctx,
739720 AV_LOG_INFO,
740721 "The following Sequence is not supported and is ignored: %s\n",
741722 sequence_elem->name);
@@ -753,7 +734,7 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 11 unmodified lines
753734 return ret;
754735 }
755736
756−int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl)
737+int ff_imf_parse_cpl_from_xml_dom(void *log_ctx, xmlDocPtr doc, FFIMFCPL **cpl)
757738 {
758739 int ret = 0;
759740 xmlNodePtr cpl_element = NULL;
@@ -766,20 +747,28 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) · 6 unmodified lines
766747
767748 cpl_element = xmlDocGetRootElement(doc);
768749 if (!cpl_element || xmlStrcmp(cpl_element->name, "CompositionPlaylist")) {
769− av_log(NULL, AV_LOG_ERROR, "The root element of the CPL is not CompositionPlaylist\n");
750+ av_log(log_ctx, AV_LOG_ERROR, "The root element of the CPL is not CompositionPlaylist\n");
770751 ret = AVERROR_INVALIDDATA;
771752 goto cleanup;
772753 }
773754
774− if ((ret = fill_content_title(cpl_element, *cpl)))
755+ if ((ret = fill_content_title(cpl_element, *cpl))) {
756+ av_log(log_ctx, AV_LOG_ERROR, "Cannot read the ContentTitle element from the IMF CPL\n");
775757 goto cleanup;
776− if ((ret = fill_id(cpl_element, *cpl)))
758+ }
759+ if ((ret = fill_id(cpl_element, *cpl))) {
760+ av_log(log_ctx, AV_LOG_ERROR, "Id element not found in the IMF CPL\n");
777761 goto cleanup;
778− if ((ret = fill_edit_rate(cpl_element, *cpl)))
762+ }
763+ if ((ret = fill_edit_rate(cpl_element, *cpl))) {
764+ av_log(log_ctx, AV_LOG_ERROR, "EditRate element not found in the IMF CPL\n");
779765 goto cleanup;
780− if ((ret = fill_timecode(cpl_element, *cpl)))
766+ }
767+ if ((ret = fill_timecode(cpl_element, *cpl))) {
768+ av_log(log_ctx, AV_LOG_ERROR, "Invalid CompositionTimecode element found in the IMF CPL\n");
781769 goto cleanup;
782− if ((ret = fill_virtual_tracks(cpl_element, *cpl)))
770+ }
771+ if ((ret = fill_virtual_tracks(log_ctx, cpl_element, *cpl)))
783772 goto cleanup;
784773
785774 cleanup:
@@ -875,7 +864,7 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) · 89 unmodified lines
875864 av_freep(&cpl);
876865 }
877866
878−int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl)
867+int ff_imf_parse_cpl(void *log_ctx, AVIOContext *in, FFIMFCPL **cpl)
879868 {
880869 AVBPrint buf;
881870 xmlDoc *doc = NULL;
@@ -885,7 +874,7 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) · 3 unmodified lines
885874
886875 ret = avio_read_to_bprint(in, &buf, SIZE_MAX);
887876 if (ret < 0 || !avio_feof(in)) {
888− av_log(NULL, AV_LOG_ERROR, "Cannot read IMF CPL\n");
877+ av_log(log_ctx, AV_LOG_ERROR, "Cannot read IMF CPL\n");
889878 if (ret == 0)
890879 ret = AVERROR_INVALIDDATA;
891880 goto clean_up;
@@ -895,21 +884,21 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) · 3 unmodified lines
895884
896885 doc = xmlReadMemory(buf.str, buf.len, NULL, NULL, 0);
897886 if (!doc) {
898− av_log(NULL,
887+ av_log(log_ctx,
899888 AV_LOG_ERROR,
900889 "XML parsing failed when reading the IMF CPL\n");
901890 ret = AVERROR_INVALIDDATA;
902891 goto clean_up;
903892 }
904893
905− if ((ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl))) {
906− av_log(NULL, AV_LOG_ERROR, "Cannot parse IMF CPL\n");
894+ if ((ret = ff_imf_parse_cpl_from_xml_dom(log_ctx, doc, cpl))) {
895+ av_log(log_ctx, AV_LOG_ERROR, "Cannot parse IMF CPL\n");
907896 } else {
908− av_log(NULL,
897+ av_log(log_ctx,
909898 AV_LOG_INFO,
910899 "IMF CPL ContentTitle: %s\n",
911900 (*cpl)->content_title_utf8);
912− av_log(NULL,
901+ av_log(log_ctx,
913902 AV_LOG_INFO,
914903 "IMF CPL Id: " AV_PRI_UUID "\n",
915904 AV_UUID_ARG((*cpl)->id_uuid));
libavformat/imfdec.c+1−1
@@ -649,7 +649,7 @@ static int imf_read_header(AVFormatContext *s) · 648 unmodified lines
649649
650650 av_log(s, AV_LOG_DEBUG, "start parsing IMF CPL: %s\n", s->url);
651651
652− if ((ret = ff_imf_parse_cpl(s->pb, &c->cpl)) < 0)
652+ if ((ret = ff_imf_parse_cpl(s, s->pb, &c->cpl)) < 0)
653653 return ret;
654654
655655 tcr = av_dict_get(s->metadata, "timecode", NULL, 0);
libavformat/tests/imf.c+2−2
@@ -341,7 +341,7 @@ static int test_cpl_parsing(void) · 340 unmodified lines
341341 return 1;
342342 }
343343
344− ret = ff_imf_parse_cpl_from_xml_dom(doc, &cpl);
344+ ret = ff_imf_parse_cpl_from_xml_dom(NULL, doc, &cpl);
345345 xmlFreeDoc(doc);
346346 if (ret) {
347347 printf("CPL parsing failed.\n");
@@ -394,7 +394,7 @@ static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pas · 46 unmodified lines
394394 return should_pass;
395395 }
396396
397− ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl);
397+ ret = ff_imf_parse_cpl_from_xml_dom(NULL, doc, cpl);
398398 xmlFreeDoc(doc);
399399 if (ret) {
400400 printf("CPL parsing failed.\n");

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