From patchwork Sun Oct 2 16:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 38520 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp866375pzh; Sun, 2 Oct 2022 09:28:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ycIDdfPsRw4jFJpwaH8Cl61NE7ziCvtm3bol/Fj1dhht1LdZjUXAl043OpNI8f3EQ9ve4 X-Received: by 2002:a05:6402:159a:b0:458:d744:8975 with SMTP id c26-20020a056402159a00b00458d7448975mr3975244edv.200.1664728091540; Sun, 02 Oct 2022 09:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664728091; cv=none; d=google.com; s=arc-20160816; b=HXT7irOlRl457e6/Io3bJuY6GtbtIuY/2pIS1lw6f1eO9SpRA4BGBqkisjNFeSTei7 HeNY07PTXbs2YVuakoZLSewPj9WLr/EAR9Ah4xz8UOYQT5eDeEuegp8nEUxfUKIOUHFR F/HhNCv8JgH0xVbXeX8yD2FKXul/HL/BVkvILWCNGGrU2f1OUEpBSRy9xWsm+yU75mF1 NmIcv3Ukn5+Gq6JD/DasyeVT8OzeS86aqXwnQZMLGaznrw31W4s0o8dGktyVp1ZTZjIp d3Az3ni7HvQfUmTDoStY2H8xFrbojqwsjXqm43hq20l3NlCs1LzVQ2QuZ1nKbsJrxR3l SgBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=AowPm4Jzo1zgNerJmnZxYMIvItR62Tj+NWyJIgcS7u4=; b=j6k8s2OHrXj5XR0xO+mOfFwI0CCm3bFh3DxJljJ6glZBNnMAdBMPNy8I33Z1gu4ksh SU/SDhJQduqlIkpjf4e7FjOOOE1+Rz+0JEMpJzm0MwLf4VufOGtClqOkL63f4l7RX/hY mJqgrXYdHqa2JkU1wOz9tmloeBwIE4dXT0Rwckl2r8qjkrR9HIJXQK5x+c9sOPkNI1xY +tR2vRGDnCUngsZPdmYMyeiHCvberjfTb6digg5cHb5Nc2QP01YwSw1wuf4o+eYhB/js wMIZvkZEeRmKa+eXPKB0wYLEj4fTf5f155wqyW8ucSdkNFkHDPMQR0oH/HiMQdX9Ioxk rq0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w25-20020a170906185900b0078239e3174bsi5459148eje.660.2022.10.02.09.28.11; Sun, 02 Oct 2022 09:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 60F4C68BB6F; Sun, 2 Oct 2022 19:28:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3537568BB08 for ; Sun, 2 Oct 2022 19:28:03 +0300 (EEST) Received: by mail-pj1-f41.google.com with SMTP id l1-20020a17090a72c100b0020a6949a66aso3567984pjk.1 for ; Sun, 02 Oct 2022 09:28:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=3Rx8qlW01hiYQ9emPcDx6e9++oOQYA5UVduf9IrIKkk=; b=Q348nRx0g6H5mC8owqtmpBt/p495zY7llJ75dqIaQ2g0LxbjPIRGKjiyIAZb8e99tk pYwwRNmoYiLx+Lj4yTgdJWCft/hbIPaeWw5vJDZMKccF1IwsJ8yCWS+2KpOrwGYPEuiE g525TtP/AHTi6CEywtwEuLv4k7SPCzFQwQdb2rEiZ18RnRGMXg1tim98ANsiNQFjUwgo LKuF7AeyEkwqcv597f2NMR/FU2/79ilcgZZe6hdWPWpZHsjNjOULa0eyUlEMV2b9R9qi fJ7PTX/qqjJZaHykeHafX4kZD0TNOhRvXdrlXx+4kZ551d9wfDzoSlRXZDe1JfYMtemy iPqg== X-Gm-Message-State: ACrzQf2gyxip4/SxXhn2ivsczWB5qXuM7LnCvd7zhDpHZqkOk0fCka+A XV0kKh5A6lhUWwJ6vGY+yE1jnay6T00= X-Received: by 2002:a17:902:e844:b0:17f:5ad3:279f with SMTP id t4-20020a170902e84400b0017f5ad3279fmr1433686plg.110.1664728081033; Sun, 02 Oct 2022 09:28:01 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id v5-20020a622f05000000b0053b2681b0e0sm5637610pfv.39.2022.10.02.09.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 09:28:00 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sun, 02 Oct 2022 09:27:56 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Oct 2022 09:27:53 -0700 Message-Id: <20221002162755.8413-1-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] avformat/imfdec: use CPL start timecode if available X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: QLGSp+zcaU7F From: Pierre-Anthony Lemieux The IMF CPL contains an optional timecode start address. This patch reads the latter, if present, into the context's timecode metadata parameter. This addresses https://trac.ffmpeg.org/ticket/9842. --- libavformat/imf.h | 2 + libavformat/imf_cpl.c | 106 ++++++++++++++++++++++++++++++++++++++++++ libavformat/imfdec.c | 11 +++++ 3 files changed, 119 insertions(+) diff --git a/libavformat/imf.h b/libavformat/imf.h index 4271cd9582..70ed007312 100644 --- a/libavformat/imf.h +++ b/libavformat/imf.h @@ -59,6 +59,7 @@ #include "libavformat/avio.h" #include "libavutil/rational.h" #include "libavutil/uuid.h" +#include "libavutil/timecode.h" #include /** @@ -130,6 +131,7 @@ typedef struct FFIMFCPL { AVUUID id_uuid; /**< CompositionPlaylist/Id element */ xmlChar *content_title_utf8; /**< CompositionPlaylist/ContentTitle element */ AVRational edit_rate; /**< CompositionPlaylist/EditRate element */ + AVTimecode *tc; /**< CompositionPlaylist/CompositionTimecode element */ FFIMFMarkerVirtualTrack *main_markers_track; /**< Main Marker Virtual Track */ FFIMFTrackFileVirtualTrack *main_image_2d_track; /**< Main Image Virtual Track */ uint32_t main_audio_track_count; /**< Number of Main Audio Virtual Tracks */ diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 474db6b7f5..183e6dd84e 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -116,6 +116,22 @@ int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) return ret; } +static int ff_imf_xml_read_boolean(xmlNodePtr element, int *value) +{ + int ret = 0; + + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + if (xmlStrcmp(element_text, "true") == 0 || xmlStrcmp(element_text, "1") == 0) + *value = 1; + else if (xmlStrcmp(element_text, "false") == 0 || xmlStrcmp(element_text, "0") == 0) + *value = 0; + else + ret = 1; + xmlFree(element_text); + + return ret; +} + static void imf_base_virtual_track_init(FFIMFBaseVirtualTrack *track) { memset(track->id_uuid, 0, sizeof(track->id_uuid)); @@ -179,6 +195,90 @@ static int fill_content_title(xmlNodePtr cpl_element, FFIMFCPL *cpl) return 0; } +static int digit_to_int(char digit) +{ + if (digit >= '0' && digit <= '9') + return digit - '0'; + return -1; +} + +/** + * Parses a string that conform to the TimecodeType used in IMF CPL and defined + * in SMPTE ST 2067-3. + * @param[in] s string to parse + * @param[out] tc_comps pointer to an array of 4 integers where the parsed HH, + * MM, SS and FF fields of the timecode are returned. + * @return 0 on success, < 0 AVERROR code on error. + */ +static int parse_cpl_tc_type(const char *s, int *tc_comps) +{ + if (av_strnlen(s, 11) != 11) + return AVERROR(EINVAL); + + for (int i = 0; i < 4; i++) { + int hi; + int lo; + + hi = digit_to_int(s[i * 3]); + lo = digit_to_int(s[i * 3 + 1]); + + if (hi == -1 || lo == -1) + return AVERROR(EINVAL); + + tc_comps[i] = 10 * hi + lo; + } + + return 0; +} + +static int fill_timecode(xmlNodePtr cpl_element, FFIMFCPL *cpl) +{ + xmlNodePtr tc_element = NULL; + xmlNodePtr element = NULL; + xmlChar *tc_str = NULL; + int df = 0; + int comps[4]; + int ret = 0; + + tc_element = ff_imf_xml_get_child_element_by_name(cpl_element, "CompositionTimecode"); + if (!tc_element) + return 0; + + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeDropFrame"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeDropFrame child element\n"); + return AVERROR_INVALIDDATA; + } + + if (ff_imf_xml_read_boolean(element, &df)) { + av_log(NULL, AV_LOG_ERROR, "TimecodeDropFrame element is invalid\n"); + return AVERROR_INVALIDDATA; + } + element = ff_imf_xml_get_child_element_by_name(tc_element, "TimecodeStartAddress"); + if (!element) { + av_log(NULL, AV_LOG_ERROR, "CompositionTimecode element is missing\ + a TimecodeStartAddress child element\n"); + return AVERROR_INVALIDDATA; + } + + tc_str = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + ret = parse_cpl_tc_type(tc_str, comps); + xmlFree(tc_str); + if (ret) + return ret; + + cpl->tc = av_malloc(sizeof(AVTimecode)); + if (!cpl->tc) + return AVERROR(ENOMEM); + ret = av_timecode_init_from_components(cpl->tc, cpl->edit_rate, + df ? AV_TIMECODE_FLAG_DROPFRAME : 0, + comps[0], comps[1], comps[2], comps[3], + NULL); + + return ret; +} + static int fill_edit_rate(xmlNodePtr cpl_element, FFIMFCPL *cpl) { xmlNodePtr element = NULL; @@ -682,6 +782,8 @@ int ff_imf_parse_cpl_from_xml_dom(xmlDocPtr doc, FFIMFCPL **cpl) goto cleanup; if ((ret = fill_edit_rate(cpl_element, *cpl))) goto cleanup; + if ((ret = fill_timecode(cpl_element, *cpl))) + goto cleanup; if ((ret = fill_virtual_tracks(cpl_element, *cpl))) goto cleanup; @@ -731,6 +833,7 @@ static void imf_cpl_init(FFIMFCPL *cpl) av_uuid_nil(cpl->id_uuid); cpl->content_title_utf8 = NULL; cpl->edit_rate = av_make_q(0, 1); + cpl->tc = NULL; cpl->main_markers_track = NULL; cpl->main_image_2d_track = NULL; cpl->main_audio_track_count = 0; @@ -753,6 +856,9 @@ void ff_imf_cpl_free(FFIMFCPL *cpl) if (!cpl) return; + if (cpl->tc) + av_freep(&cpl->tc); + xmlFree(cpl->content_title_utf8); imf_marker_virtual_track_free(cpl->main_markers_track); diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c index 4e60dcc4ba..03de9ce151 100644 --- a/libavformat/imfdec.c +++ b/libavformat/imfdec.c @@ -627,6 +627,8 @@ static int imf_read_header(AVFormatContext *s) IMFContext *c = s->priv_data; char *asset_map_path; char *tmp_str; + AVDictionaryEntry* tcr; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret = 0; c->interrupt_callback = &s->interrupt_callback; @@ -646,6 +648,15 @@ static int imf_read_header(AVFormatContext *s) if ((ret = ff_imf_parse_cpl(s->pb, &c->cpl)) < 0) return ret; + tcr = av_dict_get(s->metadata, "timecode", NULL, 0); + if (!tcr && c->cpl->tc) { + ret = av_dict_set(&s->metadata, "timecode", + av_timecode_make_string(c->cpl->tc, tc_buf, 0), 0); + if (ret) + return ret; + av_log(s, AV_LOG_INFO, "Setting timecode to IMF CPL timecode %s\n", tc_buf); + } + av_log(s, AV_LOG_DEBUG, "parsed IMF CPL: " AV_PRI_URN_UUID "\n", From patchwork Sun Oct 2 16:27:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 38521 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp866423pzh; Sun, 2 Oct 2022 09:28:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wlV8t0DMfDnhQexD93vONVO686+5kCF2T1P2ADDp0HiorzYcngwcT9euW8AmDyk3B7OhP X-Received: by 2002:aa7:d04e:0:b0:456:fa02:4d52 with SMTP id n14-20020aa7d04e000000b00456fa024d52mr15678637edo.10.1664728098881; Sun, 02 Oct 2022 09:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664728098; cv=none; d=google.com; s=arc-20160816; b=BFdsFG8cdf3rK7JoPQFcJj0ZTvG3I4BHjtBMaQbOIBOhcLUMAZMta014S9EP82TZGo 5Ear+vkMBsN57Gt33lfTJ8R5wNCxbFGnH2TIz7ABMv4w/ubSyX/RxjFnWWsMJfVZFgCo XrtzPT6qNGWLyNDVzhVLbv0B0tKF/aBLV44/TqAo4cIstiAlsLWZGP7fcjecbHEcH01t 4J9ClkBX+j+qtCXruIcwW0gbeO4k5gLUydFfKsYtBshSZ6E9QdBYBUbF6nJdFR2Z0/Pp R5YqHbJ1Ll54pv4Rrw7Rn8/KD6jlfkd2pPbyr4P3RM81iz/Q4M6FDq8TrGqreaX5RUzh hDQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=WINxfaR9OycpeTh7J2KctgKKHuE8irl0hvlkTCKona4=; b=lZi4VGqFX2w29PObsLS9yuM0GsRT1J7jH5VvXpvjXtZPtvhvKNATnzpzCNd/+OZQx6 +TJu22f6w8bQG+dK2Eu1uNCPnmw5Uu6ZzJLucriW6g/K+feWRzqQ7MAg2jb12ptQ5kcJ L3ksMQ5PUjc3eMFb9403F8OMiUMFi0g+C9N9Gl4D5FAA08TnI6OrAJrUuT+W/ETsJAzJ hhWR8kq/VkuRPIy/ujTn3cfCb36y0cbmkCMJ2ZingGzH2JbzZo/o6CM9tV8tYdAEbbTX 6S53bLCOGML9a/1pqhibJomzX2itMlX0FeRqda7RMGUKs/fCMeDxb6T0a6QvWhV7aHif a/lA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h17-20020a05640250d100b004585c0fe21csi7125155edb.536.2022.10.02.09.28.18; Sun, 02 Oct 2022 09:28:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7F7B568BBB0; Sun, 2 Oct 2022 19:28:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94C9968BB8D for ; Sun, 2 Oct 2022 19:28:11 +0300 (EEST) Received: by mail-pg1-f174.google.com with SMTP id r62so7906086pgr.12 for ; Sun, 02 Oct 2022 09:28:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=QYiLM3oXoA8TS/p93z6SSYisj6JX3UURg4vfFGHKFYA=; b=hEEB2vdPyykVR3IvawVFSAl23Lp1O/oEp3nY8T/dmHMzNyKnn/tBVgVKUxnXlOtZ4W JeXrnv6wPjaNzwMrEUduLcWVbMz7+SOTTt3cSRz025jkAaxVZvNcqUQRBLOpIxOewB8Q iXrulcoB5iaTVpP2v0eS5cRtr/du8FV6wtKcdQJbCFKQs7dNswnkJ6DmKQe4mAw4O6uE 2bChv/IFyPmMkkH4SnhHhbkQw9PVjz4G+E4TEqqQXsTKuMeRNuQnFNeJV7oXZOUpOYWZ okaLLJHN7rjYBid95XcjdRd+S1ko12cgU4W3EJwbLWRbsZilDn+X131dgJnlxAILgvlI jH5w== X-Gm-Message-State: ACrzQf1S0TtUiRmwho3rYoJz96UMc9Wygj1byHpgSv+9uQU+eb1Mlsle Q8NCfbscLUf4YDOIqlYkUkeZRPiep94= X-Received: by 2002:a05:6a00:180d:b0:540:ec09:293 with SMTP id y13-20020a056a00180d00b00540ec090293mr18981875pfa.3.1664728088935; Sun, 02 Oct 2022 09:28:08 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id d79-20020a621d52000000b0056012d934fasm2743894pfd.156.2022.10.02.09.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 09:28:08 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sun, 02 Oct 2022 09:28:06 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Oct 2022 09:27:54 -0700 Message-Id: <20221002162755.8413-2-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221002162755.8413-1-pal@sandflow.com> References: <20221002162755.8413-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] avformat/tests/imf: add CPL timecode test X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WY+T37EALc8J From: Pierre-Anthony Lemieux --- libavformat/tests/imf.c | 7 +++++++ tests/ref/fate/imf | 1 + 2 files changed, 8 insertions(+) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index a71de692f9..2cacb43f47 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -70,6 +70,11 @@ const char *cpl_doc = " urn:uuid:8e097bb0-cff7-4969-a692-bad47bfb528f" " " "" + "" + "false" + "24" + "02:10:01.23" + "" "24000 1001" "" "" @@ -288,6 +293,7 @@ static int test_cpl_parsing(void) { xmlDocPtr doc; FFIMFCPL *cpl; + char tc_buf[AV_TIMECODE_STR_SIZE]; int ret; doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); @@ -306,6 +312,7 @@ static int test_cpl_parsing(void) printf("%s\n", cpl->content_title_utf8); printf(AV_PRI_URN_UUID "\n", AV_UUID_ARG(cpl->id_uuid)); printf("%i %i\n", cpl->edit_rate.num, cpl->edit_rate.den); + printf("%s\n", av_timecode_make_string(cpl->tc, tc_buf, 0)); printf("Marker resource count: %" PRIu32 "\n", cpl->main_markers_track->resource_count); for (uint32_t i = 0; i < cpl->main_markers_track->resource_count; i++) { diff --git a/tests/ref/fate/imf b/tests/ref/fate/imf index 90b461dc5d..5093167bc7 100644 --- a/tests/ref/fate/imf +++ b/tests/ref/fate/imf @@ -1,6 +1,7 @@ FFMPEG sample content urn:uuid:8713c020-2489-45f5-a9f7-87be539e20b5 24000 1001 +02:10:01:23 Marker resource count: 2 Marker resource 0 Marker 0 From patchwork Sun Oct 2 16:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Anthony Lemieux X-Patchwork-Id: 38522 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp866469pzh; Sun, 2 Oct 2022 09:28:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FlQjNx3nNMCAs0bwS1c48RdwTjaFs1taWgFa697whp44k4pPaUTX6dhgCoO3OkXuDF0bq X-Received: by 2002:a17:906:fd8a:b0:75d:c79a:47c8 with SMTP id xa10-20020a170906fd8a00b0075dc79a47c8mr12390184ejb.389.1664728106997; Sun, 02 Oct 2022 09:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664728106; cv=none; d=google.com; s=arc-20160816; b=0COPNYZV/LdtBSLzbxoW+tyGDl3lS8EQJB4VbmmywaoE7cDZ6sLUTAdwSo94/zZzNO e3AzR6JypF+8y6jxFdtQ3FXNrspxiHre/6OPZ9x+yP3ReJIQU/gmS4IMnKpqgsCFlDd3 T1KJ3b2W31od9Bpm45zdl8Si+0FJLCmAmexAX/eERcbYNwbAiGxhNkkW9MhNAz+h29je OalIdSWLYgvYxtsMnQSQ6Vd6ioPfd41PEE0M1Axd7BVjSkTBiI7as9QLRLlALEOU6BUM voxBFJaJvULZuVQpitNY4YN3rlZFxsbh9SBCxea45KURLysubXJYlWn20K9/j6a/2FGQ Uuog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=idY+3wY4y2ebOJBKpolvOf0o3k5KVjvP76wYN9J+j1s=; b=InjKjz7wHSk5PErwhbQaQeMjRlbZMdoLR3teEaVOncQMwmo3iLfJ0k4dcJqQMH+AcT 9CUKyO+BrvBk4+hI/3lMVpT2NkDs2vqOe1Zdy3B4toz17LUXpczu8lX53s6yI009wVE9 IHVIFto6CJyZnsDMOlqLCmUDtYgUTFOD/ikkkNo+ezl0D2EFS0uzYb/Q/fzXYPqWs3TV te5EsBAbn701feN1HMAYYPfGT2oV8yHnJ+UpZh42zCt08NMy8FHLGxIjvROf9KaPF4na i+8LCw5BQo9FJb759LWWXEXBn2mKgFNmuJ98HaLqxApd3nDRp27pQp7rt46HwR31jvGV Cp2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y40-20020a50bb2b000000b00447c58358d7si6146665ede.616.2022.10.02.09.28.26; Sun, 02 Oct 2022 09:28:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 908D668BBCA; Sun, 2 Oct 2022 19:28:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9072468BB94 for ; Sun, 2 Oct 2022 19:28:16 +0300 (EEST) Received: by mail-pj1-f50.google.com with SMTP id lx7so8091981pjb.0 for ; Sun, 02 Oct 2022 09:28:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=jIM1k/dRYWhmf99rV0Nmk5T/vR/Jw8NkVwlJ/zgH6+w=; b=lqanEe43r1wv9Angag8ie36NugOYX9jYf+Ehv6wz9nQPyiDw9zQV6a0ogAa7x2h+I/ g+nUnJVFPaq5h3vbYEsYy2t/hiV+Dy9W150+4k5W1eHWHkdh5HSMrETPziaMB2iYN1V3 clCMBt9YzGeIxolDw+Xs+O0o96i/bOb/cQF5/ndMNN7JSXBD9CYYgRqtWXKqbs/3f7Iu KdpFJdixG+5pU6xxKDhpRH6qFR1uNp7c6Q7tHSAzGuPBxt40i8vbZlvLq7sPh9QDxI5B 5PASFLFuGY8rZpJI8jUBYYLtD7Dk6zOQMhToJMajwvi/Fe5VOM4FgBsM7drF2/hxk1Lg XpXw== X-Gm-Message-State: ACrzQf1E62zNbMCZEmAm6HdgquqoD8NV9codB+KBQcGealG4Ylar10Vl /aeP2h60b/d6B8qYB29fMJp/h4ANS1Q= X-Received: by 2002:a17:90a:5996:b0:203:1640:2dbf with SMTP id l22-20020a17090a599600b0020316402dbfmr8327319pji.150.1664728094163; Sun, 02 Oct 2022 09:28:14 -0700 (PDT) Received: from localhost (76-14-89-2.sf-cable.astound.net. [76.14.89.2]) by smtp.gmail.com with ESMTPSA id j194-20020a636ecb000000b00434abd19eeasm5069979pgc.78.2022.10.02.09.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 09:28:13 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Sun, 02 Oct 2022 09:28:11 -0700 From: pal@sandflow.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Oct 2022 09:27:55 -0700 Message-Id: <20221002162755.8413-3-pal@sandflow.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221002162755.8413-1-pal@sandflow.com> References: <20221002162755.8413-1-pal@sandflow.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/3] avformat/imfdec: variable initialiaztion cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Pierre-Anthony Lemieux Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2mbdNLZZZudQ From: Pierre-Anthony Lemieux --- libavformat/imf_cpl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/imf_cpl.c b/libavformat/imf_cpl.c index 183e6dd84e..ad84a68b13 100644 --- a/libavformat/imf_cpl.c +++ b/libavformat/imf_cpl.c @@ -72,10 +72,9 @@ xmlNodePtr ff_imf_xml_get_child_element_by_name(xmlNodePtr parent, const char *n int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); ret = av_uuid_urn_parse(element_text, uuid); if (ret) { av_log(NULL, AV_LOG_ERROR, "Invalid UUID\n"); @@ -88,10 +87,9 @@ int ff_imf_xml_read_uuid(xmlNodePtr element, AVUUID uuid) int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%i %i", &rational->num, &rational->den) != 2) { av_log(NULL, AV_LOG_ERROR, "Invalid rational number\n"); ret = AVERROR_INVALIDDATA; @@ -103,10 +101,9 @@ int ff_imf_xml_read_rational(xmlNodePtr element, AVRational *rational) int ff_imf_xml_read_uint32(xmlNodePtr element, uint32_t *number) { - xmlChar *element_text = NULL; int ret = 0; - element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); + xmlChar *element_text = xmlNodeListGetString(element->doc, element->xmlChildrenNode, 1); if (sscanf(element_text, "%" PRIu32, number) != 1) { av_log(NULL, AV_LOG_ERROR, "Invalid unsigned 32-bit integer"); ret = AVERROR_INVALIDDATA;