| @@ -76,10 +76,8 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) · 75 unmodified lines |
| 76 | 76 | |
| 77 | 77 | xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); |
| 78 | 78 | ret = av_uuid_urn_parse(element_text, uuid); |
| 79 | | − if (ret) { |
| 80 | | − av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n"); |
| 79 | + if (ret) |
| 81 | 80 | ret = AVERROR_INVALIDDATA; |
| 82 | | − } |
| 83 | 81 | xmlFree(element_text); |
| 84 | 82 | |
| 85 | 83 | return ret; |
| @@ -90,10 +88,8 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) · 4 unmodified lines |
| 90 | 88 | int ret = 0; |
| 91 | 89 | |
| 92 | 90 | 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) |
| 95 | 92 | ret = AVERROR_INVALIDDATA; |
| 96 | | − } |
| 97 | 93 | xmlFree(element_text); |
| 98 | 94 | |
| 99 | 95 | return ret; |
| @@ -104,10 +100,8 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) · 4 unmodified lines |
| 104 | 100 | int ret = 0; |
| 105 | 101 | |
| 106 | 102 | 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) |
| 109 | 104 | ret = AVERROR_INVALIDDATA; |
| 110 | | − } |
| 111 | 105 | xmlFree(element_text); |
| 112 | 106 | |
| 113 | 107 | return ret; |
| @@ -181,10 +175,8 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 67 unmodified lines |
| 181 | 175 | { |
| 182 | 176 | xmlNodePtr element = NULL; |
| 183 | 177 | |
| 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"))) |
| 186 | 179 | return AVERROR_INVALIDDATA; |
| 187 | | − } |
| 188 | 180 | cpl->content_title_utf8 = xmlNodeListGetString(cpl_element->doc, |
| 189 | 181 | element->xmlChildrenNode, |
| 190 | 182 | 1); |
| @@ -242,22 +234,15 @@ static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 51 unmodified lines |
| 242 | 234 | return 0; |
| 243 | 235 | |
| 244 | 236 | 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) |
| 248 | 238 | return AVERROR_INVALIDDATA; |
| 249 | | − } |
| 250 | 239 | |
| 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)) |
| 253 | 241 | return AVERROR_INVALIDDATA; |
| 254 | | − } |
| 242 | + |
| 255 | 243 | 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) |
| 259 | 245 | return AVERROR_INVALIDDATA; |
| 260 | | − } |
| 261 | 246 | |
| 262 | 247 | tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); |
| 263 | 248 | 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 |
| 280 | 265 | { |
| 281 | 266 | xmlNodePtr element = NULL; |
| 282 | 267 | |
| 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"))) |
| 285 | 269 | return AVERROR_INVALIDDATA; |
| 286 | | − } |
| 287 | 270 | |
| 288 | 271 | return ff_imf_xml_read_rational(element, &cpl->edit_rate); |
| 289 | 272 | } |
| @@ -292,10 +275,8 @@ static int fill_id(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines |
| 292 | 275 | { |
| 293 | 276 | xmlNodePtr element = NULL; |
| 294 | 277 | |
| 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"))) |
| 297 | 279 | return AVERROR_INVALIDDATA; |
| 298 | | − } |
| 299 | 280 | |
| 300 | 281 | return ff_imf_xml_read_uuid(element, cpl->id_uuid); |
| 301 | 282 | } |
| @@ -306,22 +287,19 @@ static int fill_marker(xmlNodePtr marker_elem, FFIMFMarker *marker) · 4 unmodified lines |
| 306 | 287 | int ret = 0; |
| 307 | 288 | |
| 308 | 289 | /* 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"))) |
| 311 | 291 | return AVERROR_INVALIDDATA; |
| 312 | | − } |
| 292 | + |
| 313 | 293 | if ((ret = ff_imf_xml_read_uint32(element, &marker->offset))) |
| 314 | 294 | return ret; |
| 315 | 295 | |
| 316 | 296 | /* 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"))) |
| 319 | 298 | 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))) |
| 323 | 301 | return AVERROR_INVALIDDATA; |
| 324 | | − } |
| 302 | + |
| 325 | 303 | if (!(marker->scope_utf8 = xmlGetNoNsProp(element, "scope"))) { |
| 326 | 304 | marker->scope_utf8 |
| 327 | 305 | = 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 |
| 334 | 312 | return ret; |
| 335 | 313 | } |
| 336 | 314 | |
| 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) |
| 338 | 317 | { |
| 339 | 318 | xmlNodePtr element = NULL; |
| 340 | 319 | int ret = 0; |
| @@ -343,14 +322,14 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 2 unmodified lines |
| 343 | 322 | if (!(element = ff_imf_xml_get_child_element_by_name(resource_elem, "EditRate"))) { |
| 344 | 323 | resource->edit_rate = cpl->edit_rate; |
| 345 | 324 | } 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"); |
| 347 | 326 | return ret; |
| 348 | 327 | } |
| 349 | 328 | |
| 350 | 329 | /* read EntryPoint */ |
| 351 | 330 | if ((element = ff_imf_xml_get_child_element_by_name(resource_elem, "EntryPoint"))) { |
| 352 | 331 | 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"); |
| 354 | 333 | return ret; |
| 355 | 334 | } |
| 356 | 335 | } else { |
| @@ -359,11 +338,11 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 2 unmodified lines |
| 359 | 338 | |
| 360 | 339 | /* read IntrinsicDuration */ |
| 361 | 340 | 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"); |
| 363 | 342 | return AVERROR_INVALIDDATA; |
| 364 | 343 | } |
| 365 | 344 | 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"); |
| 367 | 346 | return ret; |
| 368 | 347 | } |
| 369 | 348 | resource->duration -= resource->entry_point; |
| @@ -371,7 +350,7 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 1 unmodified line |
| 371 | 350 | /* read SourceDuration */ |
| 372 | 351 | if ((element = ff_imf_xml_get_child_element_by_name(resource_elem, "SourceDuration"))) { |
| 373 | 352 | 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"); |
| 375 | 354 | return ret; |
| 376 | 355 | } |
| 377 | 356 | } |
| @@ -383,38 +362,38 @@ static int fill_base_resource(xmlNodePtr resource_elem, FFIMFBaseResource *resou · 5 unmodified lines |
| 383 | 362 | return ret; |
| 384 | 363 | } |
| 385 | 364 | |
| 386 | | −static int fill_trackfile_resource(xmlNodePtr tf_resource_elem, |
| 365 | +static int fill_trackfile_resource(void *log_ctx, xmlNodePtr tf_resource_elem, |
| 387 | 366 | FFIMFTrackFileResource *tf_resource, |
| 388 | 367 | FFIMFCPL *cpl) |
| 389 | 368 | { |
| 390 | 369 | xmlNodePtr element = NULL; |
| 391 | 370 | int ret = 0; |
| 392 | 371 | |
| 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))) |
| 394 | 373 | return ret; |
| 395 | 374 | |
| 396 | 375 | /* read TrackFileId */ |
| 397 | 376 | if ((element = ff_imf_xml_get_child_element_by_name(tf_resource_elem, "TrackFileId"))) { |
| 398 | 377 | 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"); |
| 400 | 379 | return ret; |
| 401 | 380 | } |
| 402 | 381 | } 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"); |
| 404 | 383 | return AVERROR_INVALIDDATA; |
| 405 | 384 | } |
| 406 | 385 | |
| 407 | 386 | return ret; |
| 408 | 387 | } |
| 409 | 388 | |
| 410 | | −static int fill_marker_resource(xmlNodePtr marker_resource_elem, |
| 389 | +static int fill_marker_resource(void *log_ctx, xmlNodePtr marker_resource_elem, |
| 411 | 390 | FFIMFMarkerResource *marker_resource, |
| 412 | 391 | FFIMFCPL *cpl) |
| 413 | 392 | { |
| 414 | 393 | xmlNodePtr element = NULL; |
| 415 | 394 | int ret = 0; |
| 416 | 395 | |
| 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))) |
| 418 | 397 | return ret; |
| 419 | 398 | |
| 420 | 399 | /* read markers */ |
| @@ -436,8 +415,10 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem, · 15 unmodified lines |
| 436 | 415 | ret = fill_marker(element, |
| 437 | 416 | &marker_resource->markers[marker_resource->marker_count]); |
| 438 | 417 | marker_resource->marker_count++; |
| 439 | | − if (ret) |
| 418 | + if (ret) { |
| 419 | + av_log(log_ctx, AV_LOG_ERROR, "Invalid Marker element\n"); |
| 440 | 420 | return ret; |
| 421 | + } |
| 441 | 422 | } |
| 442 | 423 | |
| 443 | 424 | element = xmlNextElementSibling(element); |
| @@ -446,7 +427,7 @@ static int fill_marker_resource(xmlNodePtr marker_resource_elem, · 2 unmodified lines |
| 446 | 427 | return ret; |
| 447 | 428 | } |
| 448 | 429 | |
| 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) |
| 450 | 431 | { |
| 451 | 432 | int ret = 0; |
| 452 | 433 | AVUUID uuid; |
| @@ -458,14 +439,14 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 5 unmodified lines |
| 458 | 439 | |
| 459 | 440 | /* read TrackID element */ |
| 460 | 441 | 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"); |
| 462 | 443 | return AVERROR_INVALIDDATA; |
| 463 | 444 | } |
| 464 | 445 | 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"); |
| 466 | 447 | return AVERROR_INVALIDDATA; |
| 467 | 448 | } |
| 468 | | − av_log(NULL, |
| 449 | + av_log(log_ctx, |
| 469 | 450 | AV_LOG_DEBUG, |
| 470 | 451 | "Processing IMF CPL Marker Sequence for Virtual Track " AV_PRI_UUID "\n", |
| 471 | 452 | AV_UUID_ARG(uuid)); |
| @@ -479,7 +460,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 7 unmodified lines |
| 479 | 460 | av_uuid_copy(cpl->main_markers_track->base.id_uuid, uuid); |
| 480 | 461 | |
| 481 | 462 | } 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"); |
| 483 | 464 | return AVERROR_INVALIDDATA; |
| 484 | 465 | } |
| 485 | 466 | |
| @@ -496,7 +477,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 10 unmodified lines |
| 496 | 477 | cpl->main_markers_track->resource_count + resource_elem_count, |
| 497 | 478 | sizeof(FFIMFMarkerResource)); |
| 498 | 479 | 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"); |
| 500 | 481 | return AVERROR(ENOMEM); |
| 501 | 482 | } |
| 502 | 483 | cpl->main_markers_track->resources = tmp; |
| @@ -504,7 +485,7 @@ static int push_marker_sequence(xmlNodePtr marker_sequence_elem, FFIMFCPL *cpl) · 1 unmodified line |
| 504 | 485 | resource_elem = xmlFirstElementChild(resource_list_elem); |
| 505 | 486 | while (resource_elem) { |
| 506 | 487 | 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, |
| 508 | 489 | &cpl->main_markers_track->resources[cpl->main_markers_track->resource_count], |
| 509 | 490 | cpl); |
| 510 | 491 | cpl->main_markers_track->resource_count++; |
| @@ -533,7 +514,7 @@ static int has_stereo_resources(xmlNodePtr element) · 22 unmodified lines |
| 533 | 514 | return 0; |
| 534 | 515 | } |
| 535 | 516 | |
| 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) |
| 537 | 518 | { |
| 538 | 519 | int ret = 0; |
| 539 | 520 | AVUUID uuid; |
| @@ -546,14 +527,14 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 6 unmodified lines |
| 546 | 527 | |
| 547 | 528 | /* read TrackID element */ |
| 548 | 529 | 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"); |
| 550 | 531 | return AVERROR_INVALIDDATA; |
| 551 | 532 | } |
| 552 | 533 | 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"); |
| 554 | 535 | return ret; |
| 555 | 536 | } |
| 556 | | − av_log(NULL, |
| 537 | + av_log(log_ctx, |
| 557 | 538 | AV_LOG_DEBUG, |
| 558 | 539 | "Processing IMF CPL Audio Sequence for Virtual Track " AV_PRI_UUID "\n", |
| 559 | 540 | AV_UUID_ARG(uuid)); |
| @@ -597,7 +578,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 37 unmodified lines |
| 597 | 578 | (vt->resource_count + resource_elem_count) |
| 598 | 579 | * sizeof(FFIMFTrackFileResource)); |
| 599 | 580 | 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"); |
| 601 | 582 | return AVERROR(ENOMEM); |
| 602 | 583 | } |
| 603 | 584 | vt->resources = tmp; |
| @@ -605,11 +586,11 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 1 unmodified line |
| 605 | 586 | resource_elem = xmlFirstElementChild(resource_list_elem); |
| 606 | 587 | while (resource_elem) { |
| 607 | 588 | 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, |
| 609 | 590 | &vt->resources[vt->resource_count], |
| 610 | 591 | cpl); |
| 611 | 592 | if (ret) |
| 612 | | − av_log(NULL, AV_LOG_ERROR, "Invalid Resource\n"); |
| 593 | + av_log(log_ctx, AV_LOG_ERROR, "Invalid Resource\n"); |
| 613 | 594 | else |
| 614 | 595 | vt->resource_count++; |
| 615 | 596 | |
| @@ -619,7 +600,7 @@ static int push_main_audio_sequence(xmlNodePtr audio_sequence_elem, FFIMFCPL *cp · 3 unmodified lines |
| 619 | 600 | return ret; |
| 620 | 601 | } |
| 621 | 602 | |
| 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) |
| 623 | 604 | { |
| 624 | 605 | int ret = 0; |
| 625 | 606 | AVUUID uuid; |
| @@ -631,17 +612,17 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 5 unmodified lines |
| 631 | 612 | |
| 632 | 613 | /* skip stereoscopic resources */ |
| 633 | 614 | 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"); |
| 635 | 616 | return AVERROR_PATCHWELCOME; |
| 636 | 617 | } |
| 637 | 618 | |
| 638 | 619 | /* read TrackId element*/ |
| 639 | 620 | 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"); |
| 641 | 622 | return AVERROR_INVALIDDATA; |
| 642 | 623 | } |
| 643 | 624 | 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"); |
| 645 | 626 | return ret; |
| 646 | 627 | } |
| 647 | 628 | |
| @@ -654,10 +635,10 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 6 unmodified lines |
| 654 | 635 | av_uuid_copy(cpl->main_image_2d_track->base.id_uuid, uuid); |
| 655 | 636 | |
| 656 | 637 | } 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"); |
| 658 | 639 | return AVERROR_INVALIDDATA; |
| 659 | 640 | } |
| 660 | | − av_log(NULL, |
| 641 | + av_log(log_ctx, |
| 661 | 642 | AV_LOG_DEBUG, |
| 662 | 643 | "Processing IMF CPL Main Image Sequence for Virtual Track " AV_PRI_UUID "\n", |
| 663 | 644 | AV_UUID_ARG(uuid)); |
| @@ -678,7 +659,7 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 14 unmodified lines |
| 678 | 659 | (cpl->main_image_2d_track->resource_count + resource_elem_count) |
| 679 | 660 | * sizeof(FFIMFTrackFileResource)); |
| 680 | 661 | 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"); |
| 682 | 663 | return AVERROR(ENOMEM); |
| 683 | 664 | } |
| 684 | 665 | 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 |
| 687 | 668 | while (resource_elem) { |
| 688 | 669 | imf_trackfile_resource_init( |
| 689 | 670 | &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, |
| 691 | 672 | &cpl->main_image_2d_track->resources[cpl->main_image_2d_track->resource_count], |
| 692 | 673 | cpl); |
| 693 | 674 | if (ret) |
| 694 | | − av_log(NULL, AV_LOG_ERROR, "Invalid Resource\n"); |
| 675 | + av_log(log_ctx, AV_LOG_ERROR, "Invalid Resource\n"); |
| 695 | 676 | else |
| 696 | 677 | cpl->main_image_2d_track->resource_count++; |
| 697 | 678 | |
| @@ -701,7 +682,7 @@ static int push_main_image_2d_sequence(xmlNodePtr image_sequence_elem, FFIMFCPL · 3 unmodified lines |
| 701 | 682 | return 0; |
| 702 | 683 | } |
| 703 | 684 | |
| 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) |
| 705 | 686 | { |
| 706 | 687 | int ret = 0; |
| 707 | 688 | xmlNodePtr segment_list_elem = NULL; |
| @@ -710,14 +691,14 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines |
| 710 | 691 | xmlNodePtr sequence_elem = NULL; |
| 711 | 692 | |
| 712 | 693 | 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"); |
| 714 | 695 | return AVERROR_INVALIDDATA; |
| 715 | 696 | } |
| 716 | 697 | |
| 717 | 698 | /* process sequences */ |
| 718 | 699 | segment_elem = xmlFirstElementChild(segment_list_elem); |
| 719 | 700 | 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"); |
| 721 | 702 | |
| 722 | 703 | sequence_list_elem = ff_imf_xml_get_child_element_by_name(segment_elem, "SequenceList"); |
| 723 | 704 | if (!sequence_list_elem) |
| @@ -726,16 +707,16 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 2 unmodified lines |
| 726 | 707 | sequence_elem = xmlFirstElementChild(sequence_list_elem); |
| 727 | 708 | while (sequence_elem) { |
| 728 | 709 | 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); |
| 730 | 711 | |
| 731 | 712 | 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); |
| 733 | 714 | |
| 734 | 715 | 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); |
| 736 | 717 | |
| 737 | 718 | else |
| 738 | | − av_log(NULL, |
| 719 | + av_log(log_ctx, |
| 739 | 720 | AV_LOG_INFO, |
| 740 | 721 | "The following Sequence is not supported and is ignored: %s\n", |
| 741 | 722 | sequence_elem->name); |
| @@ -753,7 +734,7 @@ static int fill_virtual_tracks(xmlNodePtr cpl_element, FFIMFCPL *cpl) · 11 unmodified lines |
| 753 | 734 | return ret; |
| 754 | 735 | } |
| 755 | 736 | |
| 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) |
| 757 | 738 | { |
| 758 | 739 | int ret = 0; |
| 759 | 740 | xmlNodePtr cpl_element = NULL; |
| @@ -766,20 +747,28 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) · 6 unmodified lines |
| 766 | 747 | |
| 767 | 748 | cpl_element = xmlDocGetRootElement(doc); |
| 768 | 749 | 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"); |
| 770 | 751 | ret = AVERROR_INVALIDDATA; |
| 771 | 752 | goto cleanup; |
| 772 | 753 | } |
| 773 | 754 | |
| 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"); |
| 775 | 757 | 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"); |
| 777 | 761 | 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"); |
| 779 | 765 | 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"); |
| 781 | 769 | goto cleanup; |
| 782 | | − if ((ret = fill_virtual_tracks(cpl_element, *cpl))) |
| 770 | + } |
| 771 | + if ((ret = fill_virtual_tracks(log_ctx, cpl_element, *cpl))) |
| 783 | 772 | goto cleanup; |
| 784 | 773 | |
| 785 | 774 | cleanup: |
| @@ -875,7 +864,7 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) · 89 unmodified lines |
| 875 | 864 | av_freep(&cpl); |
| 876 | 865 | } |
| 877 | 866 | |
| 878 | | −int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) |
| 867 | +int ff_imf_parse_cpl(void *log_ctx, AVIOContext *in, FFIMFCPL **cpl) |
| 879 | 868 | { |
| 880 | 869 | AVBPrint buf; |
| 881 | 870 | xmlDoc *doc = NULL; |
| @@ -885,7 +874,7 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) · 3 unmodified lines |
| 885 | 874 | |
| 886 | 875 | ret = avio_read_to_bprint(in, &buf, SIZE_MAX); |
| 887 | 876 | 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"); |
| 889 | 878 | if (ret == 0) |
| 890 | 879 | ret = AVERROR_INVALIDDATA; |
| 891 | 880 | goto clean_up; |
| @@ -895,21 +884,21 @@ int ff_imf_parse_cpl(AVIOContext *in, FFIMFCPL **cpl) · 3 unmodified lines |
| 895 | 884 | |
| 896 | 885 | doc = xmlReadMemory(buf.str, buf.len, NULL, NULL, 0); |
| 897 | 886 | if (!doc) { |
| 898 | | − av_log(NULL, |
| 887 | + av_log(log_ctx, |
| 899 | 888 | AV_LOG_ERROR, |
| 900 | 889 | "XML parsing failed when reading the IMF CPL\n"); |
| 901 | 890 | ret = AVERROR_INVALIDDATA; |
| 902 | 891 | goto clean_up; |
| 903 | 892 | } |
| 904 | 893 | |
| 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"); |
| 907 | 896 | } else { |
| 908 | | − av_log(NULL, |
| 897 | + av_log(log_ctx, |
| 909 | 898 | AV_LOG_INFO, |
| 910 | 899 | "IMF CPL ContentTitle: %s\n", |
| 911 | 900 | (*cpl)->content_title_utf8); |
| 912 | | − av_log(NULL, |
| 901 | + av_log(log_ctx, |
| 913 | 902 | AV_LOG_INFO, |
| 914 | 903 | "IMF CPL Id: " AV_PRI_UUID "\n", |
| 915 | 904 | AV_UUID_ARG((*cpl)->id_uuid)); |