Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
The comments have been addressed in v3 of the patch. On Sun, Oct 31, 2021 at 1:22 PM Pierre-Anthony Lemieux wrote: > > On Sun, Oct 31, 2021 at 11:45 AM James Almer wrote: > > > > On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote: > > >>> The functions are not static and are defined in imf_internal.h. They > > >>> are used in both libavformat/imfdec.c and the tests at > > >>> libavformat/tests/imf.c. Ok? > > >> > > >> If they are used in libavformat only it should be static. > > > AFAIK static functions are only available in the compilation unit > > > where they are defined, so if a static function (e.g. > > > `parse_imf_asset_map_from_xml_dom()`) is defined in > > > libavformat/imf_dec.c, it will not be available in > > > libavformat/tests/imf.c. > > > > > > Functions that can be used by other FFMPEG modules are declared in > > > "imf.h", whereas functions that are intended to be used only by the > > > IMF demuxer are declared in "imf_internal.h". > > > > > > For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c" > > > include "libavformat/imf_internal.h" so they can access > > > `parse_imf_asset_map_from_xml_dom()`. > > > > > > Does that work? Any alternative? > > > > Tests in the library's test folder can and usually include the actual .c > > file from the module they are testing, so making it static will work fine. > > Ok. To summarize: > > - functions used only by "imf_.c" should be static in "imf_.c, > and tests should include "imf_.c" > - any function/structure used by both "imf_.c" and "imf_.c" > should be declared in "imf.h", even if the function/structure is not > intended to be used beyond "imf_.c" and "imf_.c" > > In other words, splitting imf-related functions into "imf.h" > (functions potentially for use beyond the IMF demuxer) and > "imf_internal.h" (functions not for use beyond the IMF demuxer) is not > desirable. > > Ok? Happy either way, just want to make sure I get the next patch > version right :) > > > > > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Sun, Oct 31, 2021 at 11:45 AM James Almer wrote: > > On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote: > >>> The functions are not static and are defined in imf_internal.h. They > >>> are used in both libavformat/imfdec.c and the tests at > >>> libavformat/tests/imf.c. Ok? > >> > >> If they are used in libavformat only it should be static. > > AFAIK static functions are only available in the compilation unit > > where they are defined, so if a static function (e.g. > > `parse_imf_asset_map_from_xml_dom()`) is defined in > > libavformat/imf_dec.c, it will not be available in > > libavformat/tests/imf.c. > > > > Functions that can be used by other FFMPEG modules are declared in > > "imf.h", whereas functions that are intended to be used only by the > > IMF demuxer are declared in "imf_internal.h". > > > > For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c" > > include "libavformat/imf_internal.h" so they can access > > `parse_imf_asset_map_from_xml_dom()`. > > > > Does that work? Any alternative? > > Tests in the library's test folder can and usually include the actual .c > file from the module they are testing, so making it static will work fine. Ok. To summarize: - functions used only by "imf_.c" should be static in "imf_.c, and tests should include "imf_.c" - any function/structure used by both "imf_.c" and "imf_.c" should be declared in "imf.h", even if the function/structure is not intended to be used beyond "imf_.c" and "imf_.c" In other words, splitting imf-related functions into "imf.h" (functions potentially for use beyond the IMF demuxer) and "imf_internal.h" (functions not for use beyond the IMF demuxer) is not desirable. Ok? Happy either way, just want to make sure I get the next patch version right :) > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On 10/31/2021 3:34 PM, Pierre-Anthony Lemieux wrote: The functions are not static and are defined in imf_internal.h. They are used in both libavformat/imfdec.c and the tests at libavformat/tests/imf.c. Ok? If they are used in libavformat only it should be static. AFAIK static functions are only available in the compilation unit where they are defined, so if a static function (e.g. `parse_imf_asset_map_from_xml_dom()`) is defined in libavformat/imf_dec.c, it will not be available in libavformat/tests/imf.c. Functions that can be used by other FFMPEG modules are declared in "imf.h", whereas functions that are intended to be used only by the IMF demuxer are declared in "imf_internal.h". For example, both "libavformat/tests/imf.c" and "libavformat/imfdec.c" include "libavformat/imf_internal.h" so they can access `parse_imf_asset_map_from_xml_dom()`. Does that work? Any alternative? Tests in the library's test folder can and usually include the actual .c file from the module they are testing, so making it static will work fine. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Sun, Oct 31, 2021 at 7:34 PM Pierre-Anthony Lemieux wrote: > On Thu, Oct 28, 2021 at 12:58 AM Paul B Mahol wrote: > > > > > > > > On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux > wrote: > >> > >> On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol wrote: > >> > > >> > > >> > > >> > On Fri, Oct 8, 2021 at 1:42 AM wrote: > >> >> > >> >> From: Pierre-Anthony Lemieux > >> >> > >> >> Signed-off-by: Pierre-Anthony Lemieux > >> >> --- > >> >> > >> >> Notes: > >> >> Implements the IMF demuxer. > >> >> > >> >> libavformat/imfdec.c | 660 > +++ > >> >> 1 file changed, 660 insertions(+) > >> >> create mode 100644 libavformat/imfdec.c > >> >> > >> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c > >> >> new file mode 100644 > >> >> index 00..0c64fe0c03 > >> >> --- /dev/null > >> >> +++ b/libavformat/imfdec.c > >> >> @@ -0,0 +1,660 @@ > >> >> +/* > >> >> + * Copyright (c) Sandflow Consulting LLC > >> >> + * > >> >> + * Redistribution and use in source and binary forms, with or > without > >> >> + * modification, are permitted provided that the following > conditions are met: > >> >> + * > >> >> + * * Redistributions of source code must retain the above copyright > notice, this > >> >> + * list of conditions and the following disclaimer. > >> >> + * * Redistributions in binary form must reproduce the above > copyright notice, > >> >> + * this list of conditions and the following disclaimer in the > documentation > >> >> + * and/or other materials provided with the distribution. > >> >> + * > >> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS "AS IS" > >> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > LIMITED TO, THE > >> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A > PARTICULAR PURPOSE > >> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR > CONTRIBUTORS BE > >> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, > OR > >> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, > PROCUREMENT OF > >> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR > BUSINESS > >> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, > WHETHER IN > >> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > OTHERWISE) > >> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF > ADVISED OF THE > >> >> + * POSSIBILITY OF SUCH DAMAGE. > >> >> + * > >> >> + * This file is part of FFmpeg. > >> >> + * > >> >> + * FFmpeg is free software; you can redistribute it and/or > >> >> + * modify it under the terms of the GNU Lesser General Public > >> >> + * License as published by the Free Software Foundation; either > >> >> + * version 2.1 of the License, or (at your option) any later > version. > >> >> + * > >> >> + * FFmpeg is distributed in the hope that it will be useful, > >> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > >> >> + * Lesser General Public License for more details. > >> >> + * > >> >> + * You should have received a copy of the GNU Lesser General Public > >> >> + * License along with FFmpeg; if not, write to the Free Software > >> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > >> >> + */ > >> >> + > >> >> +/** > >> >> + * Demuxes an IMF Composition > >> >> + * > >> >> + * References > >> >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master > Format > >> >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — > Core Constraints > >> >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — > Composition Playlist > >> >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — > Essence Component > >> >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — > Application #2 > >> >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — > Application #2 Extended > >> >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format > — Common Image Pixel Color Schemes > >> >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset > Mapping and File Segmentation > >> >> + * > >> >> + * @author Marc-Antoine Arnaud > >> >> + * @author Valentin Noel > >> >> + * @file > >> >> + * @ingroup lavu_imf > >> >> + */ > >> >> + > >> >> +#include "imf.h" > >> >> +#include "imf_internal.h" > >> >> +#include "internal.h" > >> >> +#include "libavutil/opt.h" > >> >> +#include "libavutil/bprint.h" > >> >> +#include "libavutil/avstring.h" > >> >> +#include "mxf.h" > >> >> +#include "url.h" > >> >> +#include > >> >> +#include > >> >> + > >> >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) > >> >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 > >> >> + > >> >> +typedef struct IMFVirtualTrackResourcePlaybackCtx { > >> >> +IMFAssetLocator *locator; > >> >> +
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Thu, Oct 28, 2021 at 12:58 AM Paul B Mahol wrote: > > > > On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux > wrote: >> >> On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol wrote: >> > >> > >> > >> > On Fri, Oct 8, 2021 at 1:42 AM wrote: >> >> >> >> From: Pierre-Anthony Lemieux >> >> >> >> Signed-off-by: Pierre-Anthony Lemieux >> >> --- >> >> >> >> Notes: >> >> Implements the IMF demuxer. >> >> >> >> libavformat/imfdec.c | 660 +++ >> >> 1 file changed, 660 insertions(+) >> >> create mode 100644 libavformat/imfdec.c >> >> >> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c >> >> new file mode 100644 >> >> index 00..0c64fe0c03 >> >> --- /dev/null >> >> +++ b/libavformat/imfdec.c >> >> @@ -0,0 +1,660 @@ >> >> +/* >> >> + * Copyright (c) Sandflow Consulting LLC >> >> + * >> >> + * Redistribution and use in source and binary forms, with or without >> >> + * modification, are permitted provided that the following conditions >> >> are met: >> >> + * >> >> + * * Redistributions of source code must retain the above copyright >> >> notice, this >> >> + * list of conditions and the following disclaimer. >> >> + * * Redistributions in binary form must reproduce the above copyright >> >> notice, >> >> + * this list of conditions and the following disclaimer in the >> >> documentation >> >> + * and/or other materials provided with the distribution. >> >> + * >> >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >> >> "AS IS" >> >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >> >> THE >> >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> >> PURPOSE >> >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR >> >> CONTRIBUTORS BE >> >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >> >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR >> >> BUSINESS >> >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER >> >> IN >> >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR >> >> OTHERWISE) >> >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED >> >> OF THE >> >> + * POSSIBILITY OF SUCH DAMAGE. >> >> + * >> >> + * This file is part of FFmpeg. >> >> + * >> >> + * FFmpeg is free software; you can redistribute it and/or >> >> + * modify it under the terms of the GNU Lesser General Public >> >> + * License as published by the Free Software Foundation; either >> >> + * version 2.1 of the License, or (at your option) any later version. >> >> + * >> >> + * FFmpeg is distributed in the hope that it will be useful, >> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> >> + * Lesser General Public License for more details. >> >> + * >> >> + * You should have received a copy of the GNU Lesser General Public >> >> + * License along with FFmpeg; if not, write to the Free Software >> >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >> >> 02110-1301 USA >> >> + */ >> >> + >> >> +/** >> >> + * Demuxes an IMF Composition >> >> + * >> >> + * References >> >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format >> >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core >> >> Constraints >> >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — >> >> Composition Playlist >> >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — >> >> Essence Component >> >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — >> >> Application #2 >> >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — >> >> Application #2 Extended >> >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — >> >> Common Image Pixel Color Schemes >> >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping >> >> and File Segmentation >> >> + * >> >> + * @author Marc-Antoine Arnaud >> >> + * @author Valentin Noel >> >> + * @file >> >> + * @ingroup lavu_imf >> >> + */ >> >> + >> >> +#include "imf.h" >> >> +#include "imf_internal.h" >> >> +#include "internal.h" >> >> +#include "libavutil/opt.h" >> >> +#include "libavutil/bprint.h" >> >> +#include "libavutil/avstring.h" >> >> +#include "mxf.h" >> >> +#include "url.h" >> >> +#include >> >> +#include >> >> + >> >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) >> >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 >> >> + >> >> +typedef struct IMFVirtualTrackResourcePlaybackCtx { >> >> +IMFAssetLocator *locator; >> >> +IMFTrackFileResource *resource; >> >> +AVFormatContext *ctx; >> >> +} IMFVirtualTrackResourcePlaybackCtx; >> >> + >> >> +typedef struct IMFVirtualTrackPlaybackCtx { >> >> +// Track index in
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Thu, Oct 28, 2021 at 6:32 AM Pierre-Anthony Lemieux wrote: > On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol wrote: > > > > > > > > On Fri, Oct 8, 2021 at 1:42 AM wrote: > >> > >> From: Pierre-Anthony Lemieux > >> > >> Signed-off-by: Pierre-Anthony Lemieux > >> --- > >> > >> Notes: > >> Implements the IMF demuxer. > >> > >> libavformat/imfdec.c | 660 +++ > >> 1 file changed, 660 insertions(+) > >> create mode 100644 libavformat/imfdec.c > >> > >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c > >> new file mode 100644 > >> index 00..0c64fe0c03 > >> --- /dev/null > >> +++ b/libavformat/imfdec.c > >> @@ -0,0 +1,660 @@ > >> +/* > >> + * Copyright (c) Sandflow Consulting LLC > >> + * > >> + * Redistribution and use in source and binary forms, with or without > >> + * modification, are permitted provided that the following conditions > are met: > >> + * > >> + * * Redistributions of source code must retain the above copyright > notice, this > >> + * list of conditions and the following disclaimer. > >> + * * Redistributions in binary form must reproduce the above copyright > notice, > >> + * this list of conditions and the following disclaimer in the > documentation > >> + * and/or other materials provided with the distribution. > >> + * > >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > "AS IS" > >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED > TO, THE > >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE > >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR > CONTRIBUTORS BE > >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR > BUSINESS > >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, > WHETHER IN > >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > OTHERWISE) > >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED > OF THE > >> + * POSSIBILITY OF SUCH DAMAGE. > >> + * > >> + * This file is part of FFmpeg. > >> + * > >> + * FFmpeg is free software; you can redistribute it and/or > >> + * modify it under the terms of the GNU Lesser General Public > >> + * License as published by the Free Software Foundation; either > >> + * version 2.1 of the License, or (at your option) any later version. > >> + * > >> + * FFmpeg is distributed in the hope that it will be useful, > >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > >> + * Lesser General Public License for more details. > >> + * > >> + * You should have received a copy of the GNU Lesser General Public > >> + * License along with FFmpeg; if not, write to the Free Software > >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > >> + */ > >> + > >> +/** > >> + * Demuxes an IMF Composition > >> + * > >> + * References > >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master > Format > >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — > Core Constraints > >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — > Composition Playlist > >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — > Essence Component > >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — > Application #2 > >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — > Application #2 Extended > >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — > Common Image Pixel Color Schemes > >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping > and File Segmentation > >> + * > >> + * @author Marc-Antoine Arnaud > >> + * @author Valentin Noel > >> + * @file > >> + * @ingroup lavu_imf > >> + */ > >> + > >> +#include "imf.h" > >> +#include "imf_internal.h" > >> +#include "internal.h" > >> +#include "libavutil/opt.h" > >> +#include "libavutil/bprint.h" > >> +#include "libavutil/avstring.h" > >> +#include "mxf.h" > >> +#include "url.h" > >> +#include > >> +#include > >> + > >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) > >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 > >> + > >> +typedef struct IMFVirtualTrackResourcePlaybackCtx { > >> +IMFAssetLocator *locator; > >> +IMFTrackFileResource *resource; > >> +AVFormatContext *ctx; > >> +} IMFVirtualTrackResourcePlaybackCtx; > >> + > >> +typedef struct IMFVirtualTrackPlaybackCtx { > >> +// Track index in playlist > >> +int32_t index; > >> +// Time counters > >> +AVRational current_timestamp; > >> +AVRational duration; > >> +// Resources > >> +unsigned int resource_count; > >> +IMFVirtualTrackResourcePlaybackCtx **resources; > >> +//
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Wed, Oct 27, 2021 at 12:54 AM Paul B Mahol wrote: > > > > On Fri, Oct 8, 2021 at 1:42 AM wrote: >> >> From: Pierre-Anthony Lemieux >> >> Signed-off-by: Pierre-Anthony Lemieux >> --- >> >> Notes: >> Implements the IMF demuxer. >> >> libavformat/imfdec.c | 660 +++ >> 1 file changed, 660 insertions(+) >> create mode 100644 libavformat/imfdec.c >> >> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c >> new file mode 100644 >> index 00..0c64fe0c03 >> --- /dev/null >> +++ b/libavformat/imfdec.c >> @@ -0,0 +1,660 @@ >> +/* >> + * Copyright (c) Sandflow Consulting LLC >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions are >> met: >> + * >> + * * Redistributions of source code must retain the above copyright notice, >> this >> + * list of conditions and the following disclaimer. >> + * * Redistributions in binary form must reproduce the above copyright >> notice, >> + * this list of conditions and the following disclaimer in the >> documentation >> + * and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS >> IS" >> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> PURPOSE >> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE >> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >> THE >> + * POSSIBILITY OF SUCH DAMAGE. >> + * >> + * This file is part of FFmpeg. >> + * >> + * FFmpeg is free software; you can redistribute it and/or >> + * modify it under the terms of the GNU Lesser General Public >> + * License as published by the Free Software Foundation; either >> + * version 2.1 of the License, or (at your option) any later version. >> + * >> + * FFmpeg is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + * Lesser General Public License for more details. >> + * >> + * You should have received a copy of the GNU Lesser General Public >> + * License along with FFmpeg; if not, write to the Free Software >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 >> USA >> + */ >> + >> +/** >> + * Demuxes an IMF Composition >> + * >> + * References >> + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format >> + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core >> Constraints >> + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — >> Composition Playlist >> + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence >> Component >> + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — >> Application #2 >> + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — >> Application #2 Extended >> + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common >> Image Pixel Color Schemes >> + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and >> File Segmentation >> + * >> + * @author Marc-Antoine Arnaud >> + * @author Valentin Noel >> + * @file >> + * @ingroup lavu_imf >> + */ >> + >> +#include "imf.h" >> +#include "imf_internal.h" >> +#include "internal.h" >> +#include "libavutil/opt.h" >> +#include "libavutil/bprint.h" >> +#include "libavutil/avstring.h" >> +#include "mxf.h" >> +#include "url.h" >> +#include >> +#include >> + >> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) >> +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 >> + >> +typedef struct IMFVirtualTrackResourcePlaybackCtx { >> +IMFAssetLocator *locator; >> +IMFTrackFileResource *resource; >> +AVFormatContext *ctx; >> +} IMFVirtualTrackResourcePlaybackCtx; >> + >> +typedef struct IMFVirtualTrackPlaybackCtx { >> +// Track index in playlist >> +int32_t index; >> +// Time counters >> +AVRational current_timestamp; >> +AVRational duration; >> +// Resources >> +unsigned int resource_count; >> +IMFVirtualTrackResourcePlaybackCtx **resources; >> +// Decoding cursors >> +uint32_t current_resource_index; >> +int64_t last_pts; >> +} IMFVirtualTrackPlaybackCtx; >> + >> +typedef struct IMFContext { >> +const AVClass *class; >> +const char *base_url; >> +char *asset_map_paths; >> +AVIOInterruptCB
Re: [FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
On Fri, Oct 8, 2021 at 1:42 AM wrote: > From: Pierre-Anthony Lemieux > > Signed-off-by: Pierre-Anthony Lemieux > --- > > Notes: > Implements the IMF demuxer. > > libavformat/imfdec.c | 660 +++ > 1 file changed, 660 insertions(+) > create mode 100644 libavformat/imfdec.c > > diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c > new file mode 100644 > index 00..0c64fe0c03 > --- /dev/null > +++ b/libavformat/imfdec.c > @@ -0,0 +1,660 @@ > +/* > + * Copyright (c) Sandflow Consulting LLC > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions are > met: > + * > + * * Redistributions of source code must retain the above copyright > notice, this > + * list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above copyright > notice, > + * this list of conditions and the following disclaimer in the > documentation > + * and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > "AS IS" > + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, > THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS > BE > + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR > BUSINESS > + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF > THE > + * POSSIBILITY OF SUCH DAMAGE. > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA > 02110-1301 USA > + */ > + > +/** > + * Demuxes an IMF Composition > + * > + * References > + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format > + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core > Constraints > + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — > Composition Playlist > + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — > Essence Component > + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — > Application #2 > + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — > Application #2 Extended > + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — > Common Image Pixel Color Schemes > + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping > and File Segmentation > + * > + * @author Marc-Antoine Arnaud > + * @author Valentin Noel > + * @file > + * @ingroup lavu_imf > + */ > + > +#include "imf.h" > +#include "imf_internal.h" > +#include "internal.h" > +#include "libavutil/opt.h" > +#include "libavutil/bprint.h" > +#include "libavutil/avstring.h" > +#include "mxf.h" > +#include "url.h" > +#include > +#include > + > +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) > +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 > + > +typedef struct IMFVirtualTrackResourcePlaybackCtx { > +IMFAssetLocator *locator; > +IMFTrackFileResource *resource; > +AVFormatContext *ctx; > +} IMFVirtualTrackResourcePlaybackCtx; > + > +typedef struct IMFVirtualTrackPlaybackCtx { > +// Track index in playlist > +int32_t index; > +// Time counters > +AVRational current_timestamp; > +AVRational duration; > +// Resources > +unsigned int resource_count; > +IMFVirtualTrackResourcePlaybackCtx **resources; > +// Decoding cursors > +uint32_t current_resource_index; > +int64_t last_pts; > +} IMFVirtualTrackPlaybackCtx; > + > +typedef struct IMFContext { > +const AVClass *class; > +const char *base_url; > +char *asset_map_paths; > +AVIOInterruptCB *interrupt_callback; > +AVDictionary *avio_opts; > +IMFCPL *cpl; > +IMFAssetLocatorMap *asset_locator_map; > +unsigned int track_count; > +IMFVirtualTrackPlaybackCtx **tracks; > +} IMFContext; > +
[FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
From: Pierre-Anthony Lemieux Signed-off-by: Pierre-Anthony Lemieux --- Notes: Implements the IMF demuxer. libavformat/imfdec.c | 660 +++ 1 file changed, 660 insertions(+) create mode 100644 libavformat/imfdec.c diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c new file mode 100644 index 00..0c64fe0c03 --- /dev/null +++ b/libavformat/imfdec.c @@ -0,0 +1,660 @@ +/* + * Copyright (c) Sandflow Consulting LLC + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * Demuxes an IMF Composition + * + * References + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core Constraints + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — Composition Playlist + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence Component + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — Application #2 + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — Application #2 Extended + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common Image Pixel Color Schemes + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and File Segmentation + * + * @author Marc-Antoine Arnaud + * @author Valentin Noel + * @file + * @ingroup lavu_imf + */ + +#include "imf.h" +#include "imf_internal.h" +#include "internal.h" +#include "libavutil/opt.h" +#include "libavutil/bprint.h" +#include "libavutil/avstring.h" +#include "mxf.h" +#include "url.h" +#include +#include + +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 + +typedef struct IMFVirtualTrackResourcePlaybackCtx { +IMFAssetLocator *locator; +IMFTrackFileResource *resource; +AVFormatContext *ctx; +} IMFVirtualTrackResourcePlaybackCtx; + +typedef struct IMFVirtualTrackPlaybackCtx { +// Track index in playlist +int32_t index; +// Time counters +AVRational current_timestamp; +AVRational duration; +// Resources +unsigned int resource_count; +IMFVirtualTrackResourcePlaybackCtx **resources; +// Decoding cursors +uint32_t current_resource_index; +int64_t last_pts; +} IMFVirtualTrackPlaybackCtx; + +typedef struct IMFContext { +const AVClass *class; +const char *base_url; +char *asset_map_paths; +AVIOInterruptCB *interrupt_callback; +AVDictionary *avio_opts; +IMFCPL *cpl; +IMFAssetLocatorMap *asset_locator_map; +unsigned int track_count; +IMFVirtualTrackPlaybackCtx **tracks; +} IMFContext; + +int is_url(const char *string) { +char *substr = strstr(string, "://"); +return substr != NULL; +} + +int is_unix_absolute_path(const char *string) { +char *substr = strstr(string, "/"); +int index = (int)(substr - string); +return index == 0; +} + +int is_dos_absolute_path(const char
[FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
From: Pierre-Anthony Lemieux Signed-off-by: Pierre-Anthony Lemieux --- Notes: Implements the IMF demuxer. libavformat/imfdec.c | 660 +++ 1 file changed, 660 insertions(+) create mode 100644 libavformat/imfdec.c diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c new file mode 100644 index 00..0c64fe0c03 --- /dev/null +++ b/libavformat/imfdec.c @@ -0,0 +1,660 @@ +/* + * Copyright (c) Sandflow Consulting LLC + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * Demuxes an IMF Composition + * + * References + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core Constraints + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — Composition Playlist + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence Component + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — Application #2 + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — Application #2 Extended + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common Image Pixel Color Schemes + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and File Segmentation + * + * @author Marc-Antoine Arnaud + * @author Valentin Noel + * @file + * @ingroup lavu_imf + */ + +#include "imf.h" +#include "imf_internal.h" +#include "internal.h" +#include "libavutil/opt.h" +#include "libavutil/bprint.h" +#include "libavutil/avstring.h" +#include "mxf.h" +#include "url.h" +#include +#include + +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 + +typedef struct IMFVirtualTrackResourcePlaybackCtx { +IMFAssetLocator *locator; +IMFTrackFileResource *resource; +AVFormatContext *ctx; +} IMFVirtualTrackResourcePlaybackCtx; + +typedef struct IMFVirtualTrackPlaybackCtx { +// Track index in playlist +int32_t index; +// Time counters +AVRational current_timestamp; +AVRational duration; +// Resources +unsigned int resource_count; +IMFVirtualTrackResourcePlaybackCtx **resources; +// Decoding cursors +uint32_t current_resource_index; +int64_t last_pts; +} IMFVirtualTrackPlaybackCtx; + +typedef struct IMFContext { +const AVClass *class; +const char *base_url; +char *asset_map_paths; +AVIOInterruptCB *interrupt_callback; +AVDictionary *avio_opts; +IMFCPL *cpl; +IMFAssetLocatorMap *asset_locator_map; +unsigned int track_count; +IMFVirtualTrackPlaybackCtx **tracks; +} IMFContext; + +int is_url(const char *string) { +char *substr = strstr(string, "://"); +return substr != NULL; +} + +int is_unix_absolute_path(const char *string) { +char *substr = strstr(string, "/"); +int index = (int)(substr - string); +return index == 0; +} + +int is_dos_absolute_path(const char
[FFmpeg-devel] [PATCH 3/5] avformat/imf: Demuxer implementation
From: Pierre-Anthony Lemieux Signed-off-by: Pierre-Anthony Lemieux --- Notes: Implements the IMF demuxer. libavformat/imfdec.c | 646 +++ 1 file changed, 646 insertions(+) create mode 100644 libavformat/imfdec.c diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c new file mode 100644 index 00..1dee2ba8bb --- /dev/null +++ b/libavformat/imfdec.c @@ -0,0 +1,646 @@ +/* + * This file is part of FFmpeg. + * + * Copyright (c) Sandflow Consulting LLC + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Demuxes an IMF Composition + * + * References + * OV 2067-0:2018 - SMPTE Overview Document - Interoperable Master Format + * ST 2067-2:2020 - SMPTE Standard - Interoperable Master Format — Core Constraints + * ST 2067-3:2020 - SMPTE Standard - Interoperable Master Format — Composition Playlist + * ST 2067-5:2020 - SMPTE Standard - Interoperable Master Format — Essence Component + * ST 2067-20:2016 - SMPTE Standard - Interoperable Master Format — Application #2 + * ST 2067-21:2020 - SMPTE Standard - Interoperable Master Format — Application #2 Extended + * ST 2067-102:2017 - SMPTE Standard - Interoperable Master Format — Common Image Pixel Color Schemes + * ST 429-9:2007 - SMPTE Standard - D-Cinema Packaging — Asset Mapping and File Segmentation + * + * @author Marc-Antoine Arnaud + * @author Valentin Noel + * @file + * @ingroup lavu_imf + */ + +#include "imf.h" +#include "imf_internal.h" +#include "internal.h" +#include "libavutil/opt.h" +#include "libavutil/bprint.h" +#include "libavutil/avstring.h" +#include "mxf.h" +#include "url.h" +#include +#include + +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1) +#define DEFAULT_ASSETMAP_SIZE 8 * 1024 + +typedef struct IMFVirtualTrackResourcePlaybackCtx { +IMFAssetLocator *locator; +IMFTrackFileResource *resource; +AVFormatContext *ctx; +} IMFVirtualTrackResourcePlaybackCtx; + +typedef struct IMFVirtualTrackPlaybackCtx { +// Track index in playlist +int32_t index; +// Time counters +AVRational current_timestamp; +AVRational duration; +// Resources +unsigned int resource_count; +IMFVirtualTrackResourcePlaybackCtx **resources; +// Decoding cursors +uint32_t current_resource_index; +int64_t last_pts; +} IMFVirtualTrackPlaybackCtx; + +typedef struct IMFContext { +const AVClass *class; +const char *base_url; +char *asset_map_paths; +AVIOInterruptCB *interrupt_callback; +AVDictionary *avio_opts; +IMFCPL *cpl; +IMFAssetLocatorMap *asset_locator_map; +unsigned int track_count; +IMFVirtualTrackPlaybackCtx **tracks; +} IMFContext; + +int is_url(const char *string) { +char *substr = strstr(string, "://"); +return substr != NULL; +} + +int is_unix_absolute_path(const char *string) { +char *substr = strstr(string, "/"); +int index = (int)(substr - string); +return index == 0; +} + +int is_dos_absolute_path(const char *string) { +// Absolute path case: `C:\path\to\somwhere` +char *substr = strstr(string, ":\\"); +int index = (int)(substr - string); +if (index == 1) { +return 1; +} + +// Absolute path case: `C:/path/to/somwhere` +substr = strstr(string, ":/"); +index = (int)(substr - string); +if (index == 1) { +return 1; +} + +// Network path case: `\\path\to\somwhere` +substr = strstr(string, ""); +index = (int)(substr - string); +return index == 0; +} + +int parse_imf_asset_map_from_xml_dom(AVFormatContext *s, xmlDocPtr doc, IMFAssetLocatorMap **asset_map, const char *base_url) { +xmlNodePtr asset_map_element = NULL; +xmlNodePtr node = NULL; +char *uri; +