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_canopus_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x0a,0x0e,0x0f,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 };
/* complete keys to match */
data_ptr = pkt->data;
end_ptr = pkt->data + length;
buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */
- for (; end_ptr - buf_ptr >= st->codec->channels * 4; ) {
- for (i = 0; i < st->codec->channels; i++) {
+ for (; end_ptr - buf_ptr >= st->codecpar->channels * 4; ) {
+ for (i = 0; i < st->codecpar->channels; i++) {
uint32_t sample = bytestream_get_le32(&buf_ptr);
- if (st->codec->bits_per_coded_sample == 24)
+ if (st->codecpar->bits_per_coded_sample == 24)
bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff);
else
bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff);
}
- buf_ptr += 32 - st->codec->channels*4; // always 8 channels stored SMPTE 331M
+ buf_ptr += 32 - st->codecpar->channels*4; // always 8 channels stored SMPTE 331M
}
av_shrink_packet(pkt, data_ptr - pkt->data);
return 0;
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, 14, AV_CODEC_ID_MPEG2VIDEO }, /* Type D-10 mapping of 40Mbps 525/60-I */
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14, AV_CODEC_ID_DVVIDEO }, /* DV 625 25mbps */
{ { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0d,0x01,0x03,0x01,0x02,0x05,0x00,0x00 }, 14, AV_CODEC_ID_RAWVIDEO }, /* Uncompressed Picture */
+ { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x01,0x01 }, 15, AV_CODEC_ID_HQ_HQA },
+ { { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0a,0x0e,0x0f,0x03,0x01,0x02,0x20,0x02,0x01 }, 15, AV_CODEC_ID_HQX },
{ { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0xff,0x4b,0x46,0x41,0x41,0x00,0x0d,0x4d,0x4f }, 14, AV_CODEC_ID_RAWVIDEO }, /* Legacy ?? Uncompressed Picture */
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, AV_CODEC_ID_NONE },
};
PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul);
codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
- st->codec->codec_type = codec_ul->id;
+ st->codecpar->codec_type = codec_ul->id;
if (!descriptor) {
av_log(mxf->fc, AV_LOG_INFO, "source track %d: stream %d, no descriptor found\n", source_track->track_id, st->index);
/* TODO: drop PictureEssenceCoding and SoundEssenceCompression, only check EssenceContainer */
codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->essence_codec_ul);
- st->codec->codec_id = (enum AVCodecID)codec_ul->id;
- if (st->codec->codec_id == AV_CODEC_ID_NONE) {
+ st->codecpar->codec_id = (enum AVCodecID)codec_ul->id;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
codec_ul = mxf_get_codec_ul(ff_mxf_codec_uls, &descriptor->codec_ul);
- st->codec->codec_id = (enum AVCodecID)codec_ul->id;
+ st->codecpar->codec_id = (enum AVCodecID)codec_ul->id;
}
av_log(mxf->fc, AV_LOG_VERBOSE, "%s: Universal Label: ",
- avcodec_get_name(st->codec->codec_id));
+ avcodec_get_name(st->codecpar->codec_id));
for (k = 0; k < 16; k++) {
av_log(mxf->fc, AV_LOG_VERBOSE, "%.2x",
descriptor->essence_codec_ul[k]);
mxf_parse_physical_source_package(mxf, source_track, st);
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
source_track->intra_only = mxf_is_intra_only(descriptor);
container_ul = mxf_get_codec_ul(mxf_picture_essence_container_uls, essence_container_ul);
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- st->codec->codec_id = container_ul->id;
- st->codec->width = descriptor->width;
- st->codec->height = descriptor->height; /* Field height, not frame height */
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = container_ul->id;
+ st->codecpar->width = descriptor->width;
+ st->codecpar->height = descriptor->height; /* Field height, not frame height */
switch (descriptor->frame_layout) {
case FullFrame:
- st->codec->field_order = AV_FIELD_PROGRESSIVE;
+ st->codecpar->field_order = AV_FIELD_PROGRESSIVE;
break;
case OneField:
/* Every other line is stored and needs to be duplicated. */
case MixedFields:
break;
case SegmentedFrame:
- st->codec->field_order = AV_FIELD_PROGRESSIVE;
+ st->codecpar->field_order = AV_FIELD_PROGRESSIVE;
case SeparateFields:
switch (descriptor->field_dominance) {
case MXF_TFF:
- st->codec->field_order = AV_FIELD_TT;
+ st->codecpar->field_order = AV_FIELD_TT;
break;
case MXF_BFF:
- st->codec->field_order = AV_FIELD_BB;
+ st->codecpar->field_order = AV_FIELD_BB;
break;
default:
avpriv_request_sample(mxf->fc,
break;
}
/* Turn field height into frame height. */
- st->codec->height *= 2;
+ st->codecpar->height *= 2;
break;
default:
av_log(mxf->fc, AV_LOG_INFO, "Unknown frame layout type: %d\n", descriptor->frame_layout);
}
- if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO) {
- st->codec->pix_fmt = descriptor->pix_fmt;
- if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) {
+ st->codecpar->format = descriptor->pix_fmt;
+ if (st->codecpar->format == AV_PIX_FMT_NONE) {
pix_fmt_ul = mxf_get_codec_ul(ff_mxf_pixel_format_uls,
&descriptor->essence_codec_ul);
- st->codec->pix_fmt = (enum AVPixelFormat)pix_fmt_ul->id;
- if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
- st->codec->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls,
- &descriptor->essence_codec_ul)->id;
- if (!st->codec->codec_tag) {
+ st->codecpar->format = (enum AVPixelFormat)pix_fmt_ul->id;
+ if (st->codecpar->format== AV_PIX_FMT_NONE) {
+ st->codecpar->codec_tag = mxf_get_codec_ul(ff_mxf_codec_tag_uls,
+ &descriptor->essence_codec_ul)->id;
+ if (!st->codecpar->codec_tag) {
/* support files created before RP224v10 by defaulting to UYVY422
if subsampling is 4:2:2 and component depth is 8-bit */
if (descriptor->horiz_subsampling == 2 &&
descriptor->vert_subsampling == 1 &&
descriptor->component_depth == 8) {
- st->codec->pix_fmt = AV_PIX_FMT_UYVY422;
+ st->codecpar->format = AV_PIX_FMT_UYVY422;
}
}
}
}
if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den)
st->display_aspect_ratio = descriptor->aspect_ratio;
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, essence_container_ul);
/* Only overwrite existing codec ID if it is unset or A-law, which is the default according to SMPTE RP 224. */
- if (st->codec->codec_id == AV_CODEC_ID_NONE || (st->codec->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE))
- st->codec->codec_id = (enum AVCodecID)container_ul->id;
- st->codec->channels = descriptor->channels;
- st->codec->bits_per_coded_sample = descriptor->bits_per_sample;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->codecpar->codec_id == AV_CODEC_ID_PCM_ALAW && (enum AVCodecID)container_ul->id != AV_CODEC_ID_NONE))
+ st->codecpar->codec_id = (enum AVCodecID)container_ul->id;
+ st->codecpar->channels = descriptor->channels;
+ st->codecpar->bits_per_coded_sample = descriptor->bits_per_sample;
if (descriptor->sample_rate.den > 0) {
- st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
+ st->codecpar->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num);
} else {
av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) "
st->time_base);
/* TODO: implement AV_CODEC_ID_RAWAUDIO */
- if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
- st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
else if (descriptor->bits_per_sample == 32)
- st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
- } else if (st->codec->codec_id == AV_CODEC_ID_PCM_S16BE) {
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE) {
if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
- st->codec->codec_id = AV_CODEC_ID_PCM_S24BE;
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S24BE;
else if (descriptor->bits_per_sample == 32)
- st->codec->codec_id = AV_CODEC_ID_PCM_S32BE;
- } else if (st->codec->codec_id == AV_CODEC_ID_MP2) {
+ st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_MP2) {
st->need_parsing = AVSTREAM_PARSE_FULL;
}
- } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) {
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) {
int codec_id = mxf_get_codec_ul(mxf_data_essence_container_uls,
essence_container_ul)->id;
if (codec_id >= 0 &&
}
}
if (descriptor->extradata) {
- if (!ff_alloc_extradata(st->codec, descriptor->extradata_size)) {
- memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
+ if (!ff_alloc_extradata(st->codecpar, descriptor->extradata_size)) {
+ memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size);
}
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
int coded_width = mxf_get_codec_ul(mxf_intra_only_picture_coded_width,
&descriptor->essence_codec_ul)->id;
if (coded_width)
- st->codec->width = coded_width;
+ st->codecpar->width = coded_width;
ret = ff_generate_avci_extradata(st);
if (ret < 0)
return ret;
}
- if (st->codec->codec_type != AVMEDIA_TYPE_DATA && (*essence_container_ul)[15] > 0x01) {
+ if (st->codecpar->codec_type != AVMEDIA_TYPE_DATA && (*essence_container_ul)[15] > 0x01) {
/* TODO: decode timestamps */
st->need_parsing = AVSTREAM_PARSE_TIMESTAMPS;
}
/* expect PCM with exactly one index table segment and a small (< 32) EUBC */
if (s->nb_streams != 1 ||
- s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO ||
- !is_pcm(s->streams[0]->codec->codec_id) ||
+ s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
+ !is_pcm(s->streams[0]->codecpar->codec_id) ||
mxf->nb_index_tables != 1 ||
mxf->index_tables[0].nb_segments != 1 ||
mxf->index_tables[0].segments[0]->edit_unit_byte_count >= 32)
if (mxf->op != OPAtom)
return 0;
- /* TODO: support raw video without a index if they exist */
- if (s->nb_streams != 1 || s->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(s->streams[0]->codec->codec_id))
+ /* TODO: support raw video without an index if they exist */
+ if (s->nb_streams != 1 || s->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(s->streams[0]->codecpar->codec_id))
return 0;
/* check if file already has a IndexTableSegment */
st = s->streams[0];
segment->type = IndexTableSegment;
/* stream will be treated as small EditUnitByteCount */
- segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codec->codec_id) * st->codec->channels) >> 3;
+ segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3;
segment->index_start_position = 0;
segment->index_duration = s->streams[0]->duration;
segment->index_sid = p->index_sid;
return 0;
}
-static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec,
+static int mxf_set_audio_pts(MXFContext *mxf, AVCodecParameters *par,
AVPacket *pkt)
{
MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;
- int64_t bits_per_sample = codec->bits_per_coded_sample;
+ int64_t bits_per_sample = par->bits_per_coded_sample;
if (!bits_per_sample)
- bits_per_sample = av_get_bits_per_sample(codec->codec_id);
+ bits_per_sample = av_get_bits_per_sample(par->codec_id);
pkt->pts = track->sample_count;
- if ( codec->channels <= 0
+ if ( par->channels <= 0
|| bits_per_sample <= 0
- || codec->channels * (int64_t)bits_per_sample < 8)
+ || par->channels * (int64_t)bits_per_sample < 8)
return AVERROR(EINVAL);
- track->sample_count += pkt->size / (codec->channels * (int64_t)bits_per_sample / 8);
+ track->sample_count += pkt->size / (par->channels * (int64_t)bits_per_sample / 8);
return 0;
}
return 0;
}
if (IS_KLV_KEY(klv.key, mxf_essence_element_key) ||
+ IS_KLV_KEY(klv.key, mxf_canopus_essence_element_key) ||
IS_KLV_KEY(klv.key, mxf_avid_essence_element_key)) {
int index = mxf_get_stream_index(s, &klv);
int64_t next_ofs, next_klv;
AVStream *st;
MXFTrack *track;
- AVCodecContext *codec;
+ AVCodecParameters *par;
if (index < 0) {
av_log(s, AV_LOG_ERROR,
pkt->stream_index = index;
pkt->pos = klv.offset;
- codec = st->codec;
+ par = st->codecpar;
- if (codec->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+ if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
/* mxf->current_edit_unit good - see if we have an
* index table to derive timestamps from */
MXFIndexTable *t = &mxf->index_tables[0];
* let utils.c figure out DTS since it can be < PTS if low_delay = 0 (Sony IMX30) */
pkt->pts = mxf->current_edit_unit;
}
- } else if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- ret = mxf_set_audio_pts(mxf, codec, pkt);
+ } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+ ret = mxf_set_audio_pts(mxf, par, pkt);
if (ret < 0)
return ret;
}
pkt->stream_index = 0;
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
mxf->current_edit_unit >= 0 && mxf->current_edit_unit < t->nb_ptses) {
pkt->dts = mxf->current_edit_unit + t->first_dts;
pkt->pts = t->ptses[mxf->current_edit_unit];
- } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- int ret = mxf_set_audio_pts(mxf, st->codec, pkt);
+ } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+ int ret = mxf_set_audio_pts(mxf, st->codecpar, pkt);
if (ret < 0)
return ret;
}
MXFTrack *source_track = st->priv_data;
/* if audio then truncate sample_time to EditRate */
- if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
sample_time = av_rescale_q(sample_time, st->time_base,
av_inv_q(source_track->edit_rate));
AVStream *cur_st = s->streams[i];
MXFTrack *cur_track = cur_st->priv_data;
uint64_t current_sample_count = 0;
- if (cur_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if (cur_st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
ret = mxf_compute_sample_count(mxf, i, ¤t_sample_count);
if (ret < 0)
return ret;