FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
mxfdec.c File Reference
#include <inttypes.h>
#include "libavutil/aes.h"
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavcodec/bytestream.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/timecode.h"
#include "avformat.h"
#include "internal.h"
#include "mxf.h"

Go to the source code of this file.

Data Structures

struct  MXFPartition
 
struct  MXFCryptoContext
 
struct  MXFStructuralComponent
 
struct  MXFSequence
 
struct  MXFTimecodeComponent
 
struct  MXFPulldownComponent
 
struct  MXFEssenceGroup
 
struct  MXFTaggedValue
 
struct  MXFTrack
 
struct  MXFDescriptor
 
struct  MXFIndexTableSegment
 
struct  MXFPackage
 
struct  MXFMetadataSet
 
struct  MXFIndexTable
 
struct  MXFContext
 
struct  MXFMetadataReadTableEntry
 

Macros

#define MXF_TFF   1
 
#define MXF_BFF   2
 
#define IS_KLV_KEY(x, y)   (!memcmp(x, y, sizeof(y)))
 
#define READ_STR16(type, big_endian)
 
#define SET_STR_METADATA(pb, name, str)
 
#define SET_UID_METADATA(pb, name, var, str)
 
#define SET_TS_METADATA(pb, name, var, str)
 

Typedefs

typedef int MXFMetadataReadFunc (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 

Enumerations

enum  MXFPartitionType { Header, BodyPartition, Footer }
 
enum  MXFOP {
  OP1a = 1, OP1b, OP1c, OP2a,
  OP2b, OP2c, OP3a, OP3b,
  OP3c, OPAtom, OPSONYOpt
}
 
enum  MXFWrappingScheme { Frame, Clip }
 

Functions

static int mxf_read_close (AVFormatContext *s)
 
static void mxf_free_metadataset (MXFMetadataSet **ctx, int freectx)
 
static int64_t klv_decode_ber_length (AVIOContext *pb)
 
static int mxf_read_sync (AVIOContext *pb, const uint8_t *key, unsigned size)
 
static int klv_read_packet (KLVPacket *klv, AVIOContext *pb)
 
static int mxf_get_stream_index (AVFormatContext *s, KLVPacket *klv)
 
static int mxf_get_d10_aes3_packet (AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length)
 
static int mxf_decrypt_triplet (AVFormatContext *s, AVPacket *pkt, KLVPacket *klv)
 
static int mxf_read_primer_pack (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_partition_pack (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_add_metadata_set (MXFContext *mxf, void *metadata_set)
 
static int mxf_read_cryptographic_context (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_strong_ref_array (AVIOContext *pb, UID **refs, int *count)
 
static int mxf_read_content_storage (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_source_clip (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_timecode_component (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_pulldown_component (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_track (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_sequence (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_essence_group (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_utf16_string (AVIOContext *pb, int size, char **str, int be)
 
static int mxf_read_package (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_index_entry_array (AVIOContext *pb, MXFIndexTableSegment *segment)
 
static int mxf_read_index_table_segment (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static void mxf_read_pixel_layout (AVIOContext *pb, MXFDescriptor *descriptor)
 
static int mxf_read_generic_descriptor (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_read_indirect_value (void *arg, AVIOContext *pb, int size)
 
static int mxf_read_tagged_value (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_match_uid (const UID key, const UID uid, int len)
 
static const MXFCodecULmxf_get_codec_ul (const MXFCodecUL *uls, UID *uid)
 
static voidmxf_resolve_strong_ref (MXFContext *mxf, UID *strong_ref, enum MXFMetadataSetType type)
 
static int mxf_get_sorted_table_segments (MXFContext *mxf, int *nb_sorted_segments, MXFIndexTableSegment ***sorted_segments)
 
static int mxf_absolute_bodysid_offset (MXFContext *mxf, int body_sid, int64_t offset, int64_t *offset_out)
 Computes the absolute file offset of the given essence container offset. More...
 
static int64_t mxf_essence_container_end (MXFContext *mxf, int body_sid)
 Returns the end position of the essence container with given BodySID, or zero if unknown. More...
 
static int mxf_edit_unit_absolute_offset (MXFContext *mxf, MXFIndexTable *index_table, int64_t edit_unit, int64_t *edit_unit_out, int64_t *offset_out, int nag)
 
static int mxf_compute_ptses_fake_index (MXFContext *mxf, MXFIndexTable *index_table)
 
static int mxf_compute_index_tables (MXFContext *mxf)
 Sorts and collects index table segments into index tables. More...
 
static int mxf_is_intra_only (MXFDescriptor *descriptor)
 
static int mxf_uid_to_str (UID uid, char **str)
 
static int mxf_umid_to_str (UID ul, UID uid, char **str)
 
static int mxf_add_umid_metadata (AVDictionary **pm, const char *key, MXFPackage *package)
 
static int mxf_add_timecode_metadata (AVDictionary **pm, const char *key, AVTimecode *tc)
 
static MXFTimecodeComponentmxf_resolve_timecode_component (MXFContext *mxf, UID *strong_ref)
 
static MXFPackagemxf_resolve_source_package (MXFContext *mxf, UID package_uid)
 
static MXFDescriptormxf_resolve_multidescriptor (MXFContext *mxf, MXFDescriptor *descriptor, int track_id)
 
static MXFStructuralComponentmxf_resolve_essence_group_choice (MXFContext *mxf, MXFEssenceGroup *essence_group)
 
static MXFStructuralComponentmxf_resolve_sourceclip (MXFContext *mxf, UID *strong_ref)
 
static int mxf_parse_package_comments (MXFContext *mxf, AVDictionary **pm, MXFPackage *package)
 
static int mxf_parse_physical_source_package (MXFContext *mxf, MXFTrack *source_track, AVStream *st)
 
static int mxf_parse_structural_metadata (MXFContext *mxf)
 
static int mxf_timestamp_to_str (uint64_t timestamp, char **str)
 
static int mxf_read_identification_metadata (void *arg, AVIOContext *pb, int tag, int size, UID _uid, int64_t klv_offset)
 
static int mxf_read_preface_metadata (void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 
static int mxf_metadataset_init (MXFMetadataSet *ctx, enum MXFMetadataSetType type)
 
static int mxf_read_local_tags (MXFContext *mxf, KLVPacket *klv, MXFMetadataReadFunc *read_child, int ctx_size, enum MXFMetadataSetType type)
 
static int mxf_is_partition_pack_key (UID key)
 Matches any partition pack key, in other words: More...
 
static int mxf_parse_klv (MXFContext *mxf, KLVPacket klv, MXFMetadataReadFunc *read, int ctx_size, enum MXFMetadataSetType type)
 Parses a metadata KLV. More...
 
static int mxf_seek_to_previous_partition (MXFContext *mxf)
 Seeks to the previous partition and parses it, if possible. More...
 
static int mxf_parse_handle_essence (MXFContext *mxf)
 Called when essence is encountered. More...
 
static int mxf_parse_handle_partition_or_eof (MXFContext *mxf)
 Called when the next partition or EOF is encountered. More...
 
static void mxf_compute_essence_containers (MXFContext *mxf)
 Figures out the proper offset and length of the essence container in each partition. More...
 
static int64_t round_to_kag (int64_t position, int kag_size)
 
static int is_pcm (enum AVCodecID codec_id)
 
static void mxf_handle_small_eubc (AVFormatContext *s)
 Deal with the case where for some audio atoms EditUnitByteCount is very small (2, 4..). More...
 
static int mxf_handle_missing_index_segment (MXFContext *mxf)
 Deal with the case where OPAtom files does not have any IndexTableSegments. More...
 
static void mxf_read_random_index_pack (AVFormatContext *s)
 
static int mxf_read_header (AVFormatContext *s)
 
static int64_t mxf_set_current_edit_unit (MXFContext *mxf, int64_t current_offset)
 Sets mxf->current_edit_unit based on what offset we're currently at. More...
 
static int mxf_compute_sample_count (MXFContext *mxf, int stream_index, uint64_t *sample_count)
 
static int mxf_set_audio_pts (MXFContext *mxf, AVCodecContext *codec, AVPacket *pkt)
 
static int mxf_read_packet_old (AVFormatContext *s, AVPacket *pkt)
 
static int mxf_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int mxf_probe (AVProbeData *p)
 
static int mxf_read_seek (AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
 

Variables

static const uint8_t mxf_header_partition_pack_key [] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 }
 
static const uint8_t mxf_essence_element_key [] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 }
 
static const uint8_t mxf_avid_essence_element_key [] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 }
 
static const uint8_t mxf_system_item_key [] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 }
 
static const uint8_t mxf_klv_key [] = { 0x06,0x0e,0x2b,0x34 }
 
static const uint8_t mxf_crypto_source_container_ul [] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 }
 
static const uint8_t mxf_encrypted_triplet_key [] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 }
 
static const uint8_t mxf_encrypted_essence_container [] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 }
 
static const uint8_t mxf_random_index_pack_key [] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 }
 
static const uint8_t mxf_sony_mpeg4_extradata [] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 }
 
static const uint8_t mxf_avid_project_name [] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf }
 
static const uint8_t mxf_jp2k_rsiz [] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }
 
static const uint8_t mxf_indirect_value_utf16le [] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }
 
static const uint8_t mxf_indirect_value_utf16be [] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }
 
static const MXFCodecUL mxf_picture_essence_container_uls []
 
static const MXFCodecUL mxf_intra_only_essence_container_uls []
 
static const MXFCodecUL mxf_intra_only_picture_essence_coding_uls []
 
static const MXFCodecUL mxf_sound_essence_container_uls []
 
static const MXFCodecUL mxf_data_essence_container_uls []
 
static const char *const mxf_data_essence_descriptor []
 
static const
MXFMetadataReadTableEntry 
mxf_metadata_read_table []
 
AVInputFormat ff_mxf_demuxer
 

Macro Definition Documentation

#define MXF_TFF   1

Definition at line 174 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

#define MXF_BFF   2

Definition at line 175 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

#define IS_KLV_KEY (   x,
  y 
)    (!memcmp(x, y, sizeof(y)))
#define READ_STR16 (   type,
  big_endian 
)
Value:
static int mxf_read_utf16 ## type ##_string(AVIOContext *pb, int size, char** str) \
{ \
return mxf_read_utf16_string(pb, size, str, big_endian); \
}
Bytestream IO Context.
Definition: avio.h:111
ptrdiff_t size
Definition: opengl_enc.c:101
static int mxf_read_utf16_string(AVIOContext *pb, int size, char **str, int be)
Definition: mxfdec.c:822
return
GLint GLenum type
Definition: opengl_enc.c:105

Definition at line 848 of file mxfdec.c.

#define SET_STR_METADATA (   pb,
  name,
  str 
)
Value:
do { \
if ((ret = mxf_read_utf16be_string(pb, size, &str)) < 0) \
} while (0)
const char * s
Definition: avisynth_c.h:631
if()
Definition: avfilter.c:975
ptrdiff_t size
Definition: opengl_enc.c:101
return
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition: dict.h:78
ret
Definition: avfilter.c:974
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
const char * name
Definition: opengl_enc.c:103

Definition at line 2135 of file mxfdec.c.

Referenced by mxf_read_identification_metadata(), and mxf_read_preface_metadata().

#define SET_UID_METADATA (   pb,
  name,
  var,
  str 
)
Value:
do { \
avio_read(pb, var, 16); \
if ((ret = mxf_uid_to_str(var, &str)) < 0) \
} while (0)
const char * s
Definition: avisynth_c.h:631
static int mxf_uid_to_str(UID uid, char **str)
Definition: mxfdec.c:1529
if()
Definition: avfilter.c:975
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:537
return
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition: dict.h:78
ret
Definition: avfilter.c:974
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
const char * name
Definition: opengl_enc.c:103

Definition at line 2141 of file mxfdec.c.

Referenced by mxf_read_identification_metadata().

#define SET_TS_METADATA (   pb,
  name,
  var,
  str 
)
Value:
do { \
var = avio_rb64(pb); \
if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
} while (0)
const char * s
Definition: avisynth_c.h:631
if()
Definition: avfilter.c:975
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:756
static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
Definition: mxfdec.c:2107
return
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
Definition: dict.h:78
ret
Definition: avfilter.c:974
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
const char * name
Definition: opengl_enc.c:103

Definition at line 2148 of file mxfdec.c.

Referenced by mxf_read_identification_metadata().

Typedef Documentation

typedef int MXFMetadataReadFunc(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)

Definition at line 269 of file mxfdec.c.

Enumeration Type Documentation

Enumerator
Header 
BodyPartition 
Footer 

Definition at line 58 of file mxfdec.c.

enum MXFOP
Enumerator
OP1a 
OP1b 
OP1c 
OP2a 
OP2b 
OP2c 
OP3a 
OP3b 
OP3c 
OPAtom 
OPSONYOpt 

Definition at line 64 of file mxfdec.c.

Enumerator
Frame 
Clip 

Definition at line 263 of file mxfdec.c.

Function Documentation

static int mxf_read_close ( AVFormatContext s)
static

Definition at line 3051 of file mxfdec.c.

Referenced by mxf_read_header().

static void mxf_free_metadataset ( MXFMetadataSet **  ctx,
int  freectx 
)
static

Definition at line 299 of file mxfdec.c.

Referenced by mxf_handle_missing_index_segment(), mxf_read_close(), and mxf_read_local_tags().

static int64_t klv_decode_ber_length ( AVIOContext pb)
static

Definition at line 337 of file mxfdec.c.

Referenced by klv_read_packet(), and mxf_decrypt_triplet().

static int mxf_read_sync ( AVIOContext pb,
const uint8_t key,
unsigned  size 
)
static

Definition at line 352 of file mxfdec.c.

Referenced by klv_read_packet(), and mxf_read_header().

static int klv_read_packet ( KLVPacket klv,
AVIOContext pb 
)
static
static int mxf_get_stream_index ( AVFormatContext s,
KLVPacket klv 
)
static

Definition at line 376 of file mxfdec.c.

Referenced by mxf_decrypt_triplet(), and mxf_read_packet_old().

static int mxf_get_d10_aes3_packet ( AVIOContext pb,
AVStream st,
AVPacket pkt,
int64_t  length 
)
static

Definition at line 391 of file mxfdec.c.

Referenced by mxf_read_packet_old().

static int mxf_decrypt_triplet ( AVFormatContext s,
AVPacket pkt,
KLVPacket klv 
)
static

Definition at line 419 of file mxfdec.c.

Referenced by mxf_read_packet_old().

static int mxf_read_primer_pack ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 482 of file mxfdec.c.

static int mxf_read_partition_pack ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 508 of file mxfdec.c.

Referenced by mxf_seek_to_previous_partition().

static int mxf_add_metadata_set ( MXFContext mxf,
void metadata_set 
)
static

Definition at line 668 of file mxfdec.c.

Referenced by mxf_handle_missing_index_segment(), and mxf_read_local_tags().

static int mxf_read_cryptographic_context ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 681 of file mxfdec.c.

static int mxf_read_strong_ref_array ( AVIOContext pb,
UID **  refs,
int *  count 
)
static
static int mxf_read_content_storage ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 704 of file mxfdec.c.

static int mxf_read_source_clip ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 717 of file mxfdec.c.

static int mxf_read_timecode_component ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 739 of file mxfdec.c.

static int mxf_read_pulldown_component ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 756 of file mxfdec.c.

static int mxf_read_track ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 767 of file mxfdec.c.

static int mxf_read_sequence ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 788 of file mxfdec.c.

static int mxf_read_essence_group ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 808 of file mxfdec.c.

static int mxf_read_utf16_string ( AVIOContext pb,
int  size,
char **  str,
int  be 
)
inlinestatic

Definition at line 822 of file mxfdec.c.

static int mxf_read_package ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 857 of file mxfdec.c.

static int mxf_read_index_entry_array ( AVIOContext pb,
MXFIndexTableSegment segment 
)
static

Definition at line 881 of file mxfdec.c.

Referenced by mxf_read_index_table_segment().

static int mxf_read_index_table_segment ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 907 of file mxfdec.c.

static void mxf_read_pixel_layout ( AVIOContext pb,
MXFDescriptor descriptor 
)
static

Definition at line 944 of file mxfdec.c.

Referenced by mxf_read_generic_descriptor().

static int mxf_read_generic_descriptor ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 964 of file mxfdec.c.

static int mxf_read_indirect_value ( void arg,
AVIOContext pb,
int  size 
)
static

Definition at line 1048 of file mxfdec.c.

Referenced by mxf_read_tagged_value().

static int mxf_read_tagged_value ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 1066 of file mxfdec.c.

static int mxf_match_uid ( const UID  key,
const UID  uid,
int  len 
)
static

Definition at line 1082 of file mxfdec.c.

Referenced by mxf_get_codec_ul().

static const MXFCodecUL* mxf_get_codec_ul ( const MXFCodecUL uls,
UID uid 
)
static

Definition at line 1092 of file mxfdec.c.

Referenced by mxf_is_intra_only(), and mxf_parse_structural_metadata().

static void* mxf_resolve_strong_ref ( MXFContext mxf,
UID strong_ref,
enum MXFMetadataSetType  type 
)
static
static int mxf_get_sorted_table_segments ( MXFContext mxf,
int *  nb_sorted_segments,
MXFIndexTableSegment ***  sorted_segments 
)
static

Definition at line 1158 of file mxfdec.c.

Referenced by mxf_compute_index_tables().

static int mxf_absolute_bodysid_offset ( MXFContext mxf,
int  body_sid,
int64_t  offset,
int64_t *  offset_out 
)
static

Computes the absolute file offset of the given essence container offset.

Definition at line 1226 of file mxfdec.c.

Referenced by mxf_edit_unit_absolute_offset().

static int64_t mxf_essence_container_end ( MXFContext mxf,
int  body_sid 
)
static

Returns the end position of the essence container with given BodySID, or zero if unknown.

Definition at line 1255 of file mxfdec.c.

Referenced by mxf_read_packet().

static int mxf_edit_unit_absolute_offset ( MXFContext mxf,
MXFIndexTable index_table,
int64_t  edit_unit,
int64_t *  edit_unit_out,
int64_t *  offset_out,
int  nag 
)
static

Definition at line 1276 of file mxfdec.c.

Referenced by mxf_read_packet(), mxf_read_seek(), and mxf_set_current_edit_unit().

static int mxf_compute_ptses_fake_index ( MXFContext mxf,
MXFIndexTable index_table 
)
static

We have this:

x TemporalOffset 0: 0 1: 1 2: 1 3: -2 4: 1 5: 1 6: -2

We want to transform it into this:

x DTS PTS 0: -1 0 1: 0 3 2: 1 1 3: 2 2 4: 3 6 5: 4 4 6: 5 5

We do this by bucket sorting x by x+TemporalOffset[x] into mxf->ptses, then settings mxf->first_dts = -max(TemporalOffset[x]). The latter makes DTS <= PTS.

Definition at line 1324 of file mxfdec.c.

Referenced by mxf_compute_index_tables().

static int mxf_compute_index_tables ( MXFContext mxf)
static

Sorts and collects index table segments into index tables.

Also computes PTSes if possible.

Definition at line 1429 of file mxfdec.c.

Referenced by mxf_read_header().

static int mxf_is_intra_only ( MXFDescriptor descriptor)
static

Definition at line 1521 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

static int mxf_uid_to_str ( UID  uid,
char **  str 
)
static

Definition at line 1529 of file mxfdec.c.

static int mxf_umid_to_str ( UID  ul,
UID  uid,
char **  str 
)
static

Definition at line 1547 of file mxfdec.c.

Referenced by mxf_add_umid_metadata().

static int mxf_add_umid_metadata ( AVDictionary **  pm,
const char *  key,
MXFPackage package 
)
static

Definition at line 1568 of file mxfdec.c.

Referenced by mxf_parse_physical_source_package(), and mxf_parse_structural_metadata().

static int mxf_add_timecode_metadata ( AVDictionary **  pm,
const char *  key,
AVTimecode tc 
)
static

Definition at line 1580 of file mxfdec.c.

Referenced by mxf_parse_physical_source_package(), and mxf_parse_structural_metadata().

static MXFTimecodeComponent* mxf_resolve_timecode_component ( MXFContext mxf,
UID strong_ref 
)
static

Definition at line 1588 of file mxfdec.c.

Referenced by mxf_parse_physical_source_package().

static MXFPackage* mxf_resolve_source_package ( MXFContext mxf,
UID  package_uid 
)
static
static MXFDescriptor* mxf_resolve_multidescriptor ( MXFContext mxf,
MXFDescriptor descriptor,
int  track_id 
)
static

Definition at line 1625 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

static MXFStructuralComponent* mxf_resolve_essence_group_choice ( MXFContext mxf,
MXFEssenceGroup essence_group 
)
static

Definition at line 1651 of file mxfdec.c.

Referenced by mxf_resolve_sourceclip().

static MXFStructuralComponent* mxf_resolve_sourceclip ( MXFContext mxf,
UID strong_ref 
)
static

Definition at line 1678 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

static int mxf_parse_package_comments ( MXFContext mxf,
AVDictionary **  pm,
MXFPackage package 
)
static

Definition at line 1696 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

static int mxf_parse_physical_source_package ( MXFContext mxf,
MXFTrack source_track,
AVStream st 
)
static

Definition at line 1718 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

static int mxf_parse_structural_metadata ( MXFContext mxf)
static

Definition at line 1778 of file mxfdec.c.

Referenced by mxf_read_header().

static int mxf_timestamp_to_str ( uint64_t  timestamp,
char **  str 
)
static

Definition at line 2107 of file mxfdec.c.

static int mxf_read_identification_metadata ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  _uid,
int64_t  klv_offset 
)
static

Definition at line 2155 of file mxfdec.c.

static int mxf_read_preface_metadata ( void arg,
AVIOContext pb,
int  tag,
int  size,
UID  uid,
int64_t  klv_offset 
)
static

Definition at line 2192 of file mxfdec.c.

static int mxf_metadataset_init ( MXFMetadataSet ctx,
enum MXFMetadataSetType  type 
)
static

Definition at line 2245 of file mxfdec.c.

Referenced by mxf_read_local_tags().

static int mxf_read_local_tags ( MXFContext mxf,
KLVPacket klv,
MXFMetadataReadFunc read_child,
int  ctx_size,
enum MXFMetadataSetType  type 
)
static

Definition at line 2259 of file mxfdec.c.

Referenced by mxf_parse_klv().

static int mxf_is_partition_pack_key ( UID  key)
static

Matches any partition pack key, in other words:

  • HeaderPartition
  • BodyPartition
  • FooterPartition
    Returns
    non-zero if the key is a partition pack key, zero otherwise

Definition at line 2324 of file mxfdec.c.

Referenced by mxf_read_header(), and mxf_seek_to_previous_partition().

static int mxf_parse_klv ( MXFContext mxf,
KLVPacket  klv,
MXFMetadataReadFunc read,
int  ctx_size,
enum MXFMetadataSetType  type 
)
static

Parses a metadata KLV.

Returns
<0 on error, 0 otherwise

Definition at line 2335 of file mxfdec.c.

Referenced by mxf_read_header(), and mxf_seek_to_previous_partition().

static int mxf_seek_to_previous_partition ( MXFContext mxf)
static

Seeks to the previous partition and parses it, if possible.

Returns
<= 0 if we should stop parsing, > 0 if we should keep going

Definition at line 2366 of file mxfdec.c.

Referenced by mxf_parse_handle_essence(), and mxf_parse_handle_partition_or_eof().

static int mxf_parse_handle_essence ( MXFContext mxf)
static

Called when essence is encountered.

Returns
<= 0 if we should stop parsing, > 0 if we should keep going

Definition at line 2417 of file mxfdec.c.

Referenced by mxf_read_header().

static int mxf_parse_handle_partition_or_eof ( MXFContext mxf)
static

Called when the next partition or EOF is encountered.

Returns
<= 0 if we should stop parsing, > 0 if we should keep going

Definition at line 2460 of file mxfdec.c.

Referenced by mxf_read_header().

static void mxf_compute_essence_containers ( MXFContext mxf)
static

Figures out the proper offset and length of the essence container in each partition.

Definition at line 2468 of file mxfdec.c.

Referenced by mxf_read_header().

static int64_t round_to_kag ( int64_t  position,
int  kag_size 
)
static

Definition at line 2498 of file mxfdec.c.

Referenced by mxf_read_header().

static int is_pcm ( enum AVCodecID  codec_id)
static

Definition at line 2506 of file mxfdec.c.

Referenced by mxf_handle_missing_index_segment(), and mxf_handle_small_eubc().

static void mxf_handle_small_eubc ( AVFormatContext s)
static

Deal with the case where for some audio atoms EditUnitByteCount is very small (2, 4..).

In those cases we should read more than one sample per call to mxf_read_packet().

Definition at line 2517 of file mxfdec.c.

Referenced by mxf_read_header().

static int mxf_handle_missing_index_segment ( MXFContext mxf)
static

Deal with the case where OPAtom files does not have any IndexTableSegments.

Definition at line 2545 of file mxfdec.c.

Referenced by mxf_read_header().

static void mxf_read_random_index_pack ( AVFormatContext s)
static

Definition at line 2600 of file mxfdec.c.

Referenced by mxf_read_header().

static int mxf_read_header ( AVFormatContext s)
static

Definition at line 2651 of file mxfdec.c.

static int64_t mxf_set_current_edit_unit ( MXFContext mxf,
int64_t  current_offset 
)
static

Sets mxf->current_edit_unit based on what offset we're currently at.

Returns
next_ofs if OK, <0 on error

Definition at line 2789 of file mxfdec.c.

Referenced by mxf_read_packet_old().

static int mxf_compute_sample_count ( MXFContext mxf,
int  stream_index,
uint64_t *  sample_count 
)
static

Definition at line 2826 of file mxfdec.c.

Referenced by mxf_read_seek().

static int mxf_set_audio_pts ( MXFContext mxf,
AVCodecContext codec,
AVPacket pkt 
)
static

Definition at line 2867 of file mxfdec.c.

Referenced by mxf_read_packet(), and mxf_read_packet_old().

static int mxf_read_packet_old ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 2886 of file mxfdec.c.

Referenced by mxf_read_packet().

static int mxf_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 2986 of file mxfdec.c.

static int mxf_probe ( AVProbeData p)
static

Definition at line 3081 of file mxfdec.c.

static int mxf_read_seek ( AVFormatContext s,
int  stream_index,
int64_t  sample_time,
int  flags 
)
static

Definition at line 3108 of file mxfdec.c.

Variable Documentation

const uint8_t mxf_header_partition_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02 }
static

Definition at line 281 of file mxfdec.c.

Referenced by mxf_is_partition_pack_key(), mxf_probe(), and mxf_read_header().

const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 }
static
const uint8_t mxf_avid_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0e,0x04,0x03,0x01 }
static

Definition at line 283 of file mxfdec.c.

Referenced by mxf_read_header(), and mxf_read_packet_old().

const uint8_t mxf_system_item_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x03,0x01,0x04 }
static

Definition at line 284 of file mxfdec.c.

Referenced by mxf_read_header().

const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 }
static

Definition at line 285 of file mxfdec.c.

Referenced by klv_read_packet().

const uint8_t mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 }
static

Definition at line 287 of file mxfdec.c.

Referenced by mxf_read_cryptographic_context().

const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 }
static

Definition at line 288 of file mxfdec.c.

Referenced by mxf_read_header(), and mxf_read_packet_old().

const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 }
static

Definition at line 289 of file mxfdec.c.

Referenced by mxf_parse_structural_metadata().

const uint8_t mxf_random_index_pack_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x11,0x01,0x00 }
static

Definition at line 290 of file mxfdec.c.

Referenced by mxf_read_random_index_pack().

const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 }
static

Definition at line 291 of file mxfdec.c.

Referenced by mxf_read_generic_descriptor().

const uint8_t mxf_avid_project_name[] = { 0xa5,0xfb,0x7b,0x25,0xf6,0x15,0x94,0xb9,0x62,0xfc,0x37,0x17,0x49,0x2d,0x42,0xbf }
static

Definition at line 292 of file mxfdec.c.

Referenced by mxf_read_preface_metadata().

const uint8_t mxf_jp2k_rsiz[] = { 0x06,0x0e,0x2b,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }
static

Definition at line 293 of file mxfdec.c.

Referenced by mxf_read_generic_descriptor().

const uint8_t mxf_indirect_value_utf16le[] = { 0x4c,0x00,0x02,0x10,0x01,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }
static

Definition at line 294 of file mxfdec.c.

Referenced by mxf_read_indirect_value().

const uint8_t mxf_indirect_value_utf16be[] = { 0x42,0x01,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x06,0x0e,0x2b,0x34,0x01,0x04,0x01,0x01 }
static

Definition at line 295 of file mxfdec.c.

Referenced by mxf_read_indirect_value().

const MXFCodecUL mxf_picture_essence_container_uls[]
static
Initial value:
= {
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14, AV_CODEC_ID_MPEG2VIDEO },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14, AV_CODEC_ID_DVVIDEO },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14, AV_CODEC_ID_RAWVIDEO },
{ { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14, AV_CODEC_ID_RAWVIDEO },
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
}
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:107

Definition at line 1117 of file mxfdec.c.

const MXFCodecUL mxf_intra_only_essence_container_uls[]
static
Initial value:
= {
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x00,0x00 }, 14, AV_CODEC_ID_MPEG2VIDEO },
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
}
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:107

Definition at line 1127 of file mxfdec.c.

const MXFCodecUL mxf_intra_only_picture_essence_coding_uls[]
static
Initial value:
= {
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14, AV_CODEC_ID_H264 },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, AV_CODEC_ID_JPEG2000 },
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
}

Definition at line 1133 of file mxfdec.c.

const MXFCodecUL mxf_sound_essence_container_uls[]
static
Initial value:
= {
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, AV_CODEC_ID_PCM_S16LE },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x02,0x0d,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, AV_CODEC_ID_MP2 },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, AV_CODEC_ID_PCM_S16LE },
{ { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4F }, 14, AV_CODEC_ID_PCM_S16LE },
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x03,0x04,0x02,0x02,0x02,0x03,0x03,0x01,0x00 }, 14, AV_CODEC_ID_AAC },
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
}

Definition at line 1139 of file mxfdec.c.

const MXFCodecUL mxf_data_essence_container_uls[]
static
Initial value:
= {
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x09,0x0d,0x01,0x03,0x01,0x02,0x0e,0x00,0x00 }, 16, 0 },
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
}

Definition at line 1149 of file mxfdec.c.

const char* const mxf_data_essence_descriptor[]
static
Initial value:
= {
"vbi_vanc_smpte_436M",
}

Definition at line 1154 of file mxfdec.c.

const MXFMetadataReadTableEntry mxf_metadata_read_table[]
static

Definition at line 2205 of file mxfdec.c.

AVInputFormat ff_mxf_demuxer
Initial value:
= {
.name = "mxf",
.long_name = NULL_IF_CONFIG_SMALL("MXF (Material eXchange Format)"),
.priv_data_size = sizeof(MXFContext),
}
static int mxf_probe(AVProbeData *p)
Definition: mxfdec.c:3081
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
Definition: mxfdec.c:3108
static int mxf_read_header(AVFormatContext *s)
Definition: mxfdec.c:2651
static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mxfdec.c:2986
static int mxf_read_close(AVFormatContext *s)
Definition: mxfdec.c:3051
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:620
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42

Definition at line 3177 of file mxfdec.c.