Skip to content

Commit

Permalink
Add initial CPL model and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
palemieux committed Jun 3, 2021
1 parent 26f58ef commit b50932e
Show file tree
Hide file tree
Showing 5 changed files with 914 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libavformat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ OBJS-$(CONFIG_IMAGE_WEBP_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_XBM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_XPM_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMAGE_XWD_PIPE_DEMUXER) += img2dec.o img2.o
OBJS-$(CONFIG_IMF_DEMUXER) += imfdec.o
OBJS-$(CONFIG_IMF_DEMUXER) += imfdec.o imf_cpl.o
OBJS-$(CONFIG_INGENIENT_DEMUXER) += ingenientdec.o rawdec.o
OBJS-$(CONFIG_IPMOVIE_DEMUXER) += ipmovie.o
OBJS-$(CONFIG_IPU_DEMUXER) += ipudec.o
Expand Down Expand Up @@ -690,6 +690,7 @@ TESTPROGS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh
TESTPROGS-$(CONFIG_MOV_MUXER) += movenc
TESTPROGS-$(CONFIG_NETWORK) += noproxy
TESTPROGS-$(CONFIG_SRTP) += srtp
TESTPROGS-$(CONFIG_IMF_DEMUXER) += imf

TOOLS = aviocat \
ismindex \
Expand Down
121 changes: 121 additions & 0 deletions libavformat/imf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* 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.
*/

/**
* @file
* @ingroup lavu_imf
* Public header for processing of Interoperable Master Format packages
*/

#ifndef AVCODEC_IMF_H
#define AVCODEC_IMF_H

#include "libavformat/avio.h"
#include "libavutil/rational.h"
#include <libxml/tree.h>

/**
* IMF Composition Playlist Base Resource
*/
typedef struct IMFBaseResource {
AVRational edit_rate;
unsigned long entry_point;
unsigned long duration;
unsigned long repeat_count;
} IMFBaseResource;

/**
* IMF Composition Playlist Track File Resource
*/
typedef struct IMFTrackFileResource {
IMFBaseResource base;
unsigned char track_file_uuid[16];
} IMFTrackFileResource;

/**
* IMF Marker
*/
typedef struct IMFMarker {
xmlChar *label_utf8;
xmlChar *scope_utf8;
unsigned long offset;
} IMFMarker;

/**
* IMF Composition Playlist Marker Resource
*/
typedef struct IMFMarkerResource {
IMFBaseResource base;
unsigned long marker_count;
IMFMarker *markers;
} IMFMarkerResource;

/**
* IMF Composition Playlist Virtual Track
*/
typedef struct IMFBaseVirtualTrack {
unsigned char id_uuid[16];
} IMFBaseVirtualTrack;

/**
* IMF Composition Playlist Virtual Track that consists of Track File Resources
*/
typedef struct IMFTrackFileVirtualTrack {
IMFBaseVirtualTrack base;
unsigned long resource_count;
IMFTrackFileResource *resources;
} IMFTrackFileVirtualTrack;

/**
* IMF Composition Playlist Virtual Track that consists of Marker Resources
*/
typedef struct IMFMarkerVirtualTrack {
IMFBaseVirtualTrack base;
unsigned long resource_count;
IMFMarkerResource *resources;
} IMFMarkerVirtualTrack;

/**
* IMF Composition Playlist
*/
typedef struct IMFCPL {
uint8_t id_uuid[16];
xmlChar *content_title_utf8;
AVRational edit_rate;
IMFMarkerVirtualTrack *main_markers_track;
IMFTrackFileVirtualTrack *main_image_2d_track;
unsigned long main_audio_track_count;
IMFTrackFileVirtualTrack *main_audio_tracks;
} IMFCPL;

int parse_imf_cpl_from_xml_dom(xmlDocPtr doc, IMFCPL **cpl);

int parse_imf_cpl(AVIOContext *in, IMFCPL **cpl);

IMFCPL *imf_cpl_alloc(void);

void imf_cpl_free(IMFCPL *cpl);

#endif
Loading

0 comments on commit b50932e

Please sign in to comment.