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;
}
}
- av_dlog(mxf->fc,
+ av_log(mxf->fc, AV_LOG_TRACE,
"PartitionPack: ThisPartition = 0x%"PRIX64
", PreviousPartition = 0x%"PRIX64", "
"FooterPartition = 0x%"PRIX64", IndexSID = %i, BodySID = %i\n",
switch(tag) {
case 0x3F05:
segment->edit_unit_byte_count = avio_rb32(pb);
- av_dlog(NULL, "EditUnitByteCount %d\n", segment->edit_unit_byte_count);
+ av_log(NULL, AV_LOG_TRACE, "EditUnitByteCount %d\n", segment->edit_unit_byte_count);
break;
case 0x3F06:
segment->index_sid = avio_rb32(pb);
- av_dlog(NULL, "IndexSID %d\n", segment->index_sid);
+ av_log(NULL, AV_LOG_TRACE, "IndexSID %d\n", segment->index_sid);
break;
case 0x3F07:
segment->body_sid = avio_rb32(pb);
- av_dlog(NULL, "BodySID %d\n", segment->body_sid);
+ av_log(NULL, AV_LOG_TRACE, "BodySID %d\n", segment->body_sid);
break;
case 0x3F0A:
- av_dlog(NULL, "IndexEntryArray found\n");
+ av_log(NULL, AV_LOG_TRACE, "IndexEntryArray found\n");
return mxf_read_index_entry_array(pb, segment);
case 0x3F0B:
segment->index_edit_rate.num = avio_rb32(pb);
segment->index_edit_rate.den = avio_rb32(pb);
- av_dlog(NULL, "IndexEditRate %d/%d\n", segment->index_edit_rate.num,
+ av_log(NULL, AV_LOG_TRACE, "IndexEditRate %d/%d\n", segment->index_edit_rate.num,
segment->index_edit_rate.den);
break;
case 0x3F0C:
segment->index_start_position = avio_rb64(pb);
- av_dlog(NULL, "IndexStartPosition %"PRId64"\n", segment->index_start_position);
+ av_log(NULL, AV_LOG_TRACE, "IndexStartPosition %"PRId64"\n", segment->index_start_position);
break;
case 0x3F0D:
segment->index_duration = avio_rb64(pb);
- av_dlog(NULL, "IndexDuration %"PRId64"\n", segment->index_duration);
+ av_log(NULL, AV_LOG_TRACE, "IndexDuration %"PRId64"\n", segment->index_duration);
break;
}
return 0;
do {
code = avio_r8(pb);
value = avio_r8(pb);
- av_dlog(NULL, "pixel layout: code %#x\n", code);
+ av_log(NULL, AV_LOG_TRACE, "pixel layout: code %#x\n", code);
if (ofs <= 14) {
layout[ofs++] = code;
if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) {
av_free(descriptor->extradata);
descriptor->extradata_size = 0;
- descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+ descriptor->extradata = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!descriptor->extradata)
return AVERROR(ENOMEM);
descriptor->extradata_size = size;
MXFPackage *temp_package = NULL;
int i, j, k, ret;
- av_dlog(mxf->fc, "metadata sets count %d\n", mxf->metadata_sets_count);
+ av_log(mxf->fc, AV_LOG_TRACE, "metadata sets count %d\n", mxf->metadata_sets_count);
/* TODO: handle multiple material packages (OP3x) */
for (i = 0; i < mxf->packages_count; i++) {
material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage);
}
}
if (!source_package) {
- av_dlog(mxf->fc, "material track %d: no corresponding source package found\n", material_track->track_id);
+ av_log(mxf->fc, AV_LOG_TRACE, "material track %d: no corresponding source package found\n", material_track->track_id);
break;
}
for (k = 0; k < source_package->tracks_count; k++) {
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;
source_package->descriptor = mxf_resolve_strong_ref(mxf, &source_package->descriptor_ref, AnyType);
if (source_package->descriptor) {
/* 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 = codec_ul->id;
+ st->codecpar->codec_id = codec_ul->id;
- 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;
+ if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
+ st->codecpar->codec_id = container_ul->id;
+ st->codecpar->width = descriptor->width;
/* Field height, not frame height */
- st->codec->height = descriptor->height;
+ st->codecpar->height = descriptor->height;
switch (descriptor->frame_layout) {
case SegmentedFrame:
/* This one is a weird layout I don't fully understand. */
"SegmentedFrame layout isn't currently supported\n");
break;
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:
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 = pix_fmt_ul->id;
- if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
+ st->codecpar->format = pix_fmt_ul->id;
+ if (st->codecpar->format == AV_PIX_FMT_NONE) {
/* 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;
}
}
}
snprintf(source_origin, sizeof(source_origin), "%d", source_track->sequence->origin);
av_dict_set(&st->metadata, "source_track_origin", source_origin, 0);
}
- } 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);
- if (st->codec->codec_id == AV_CODEC_ID_NONE)
- st->codec->codec_id = 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 = 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) {
- st->codec->extradata = av_mallocz(descriptor->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (st->codec->extradata) {
- memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
- st->codec->extradata_size = descriptor->extradata_size;
+ st->codecpar->extradata = av_mallocz(descriptor->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (st->codecpar->extradata) {
+ memcpy(st->codecpar->extradata, descriptor->extradata, descriptor->extradata_size);
+ st->codecpar->extradata_size = descriptor->extradata_size;
}
- } else if (st->codec->codec_id == AV_CODEC_ID_H264) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
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;
}
uint64_t next = avio_tell(pb) + size;
UID uid = {0};
- av_dlog(mxf->fc, "local tag %#04x size %d\n", tag, size);
+ av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size);
if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */
av_log(mxf->fc, AV_LOG_ERROR, "local tag %#04x with 0 size\n", tag);
continue;
int local_tag = AV_RB16(mxf->local_tags+i*18);
if (local_tag == tag) {
memcpy(uid, mxf->local_tags+i*18+2, 16);
- av_dlog(mxf->fc, "local tag %#04x\n", local_tag);
+ av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x\n", local_tag);
PRINT_KEY(mxf->fc, "uid", uid);
}
}
avio_seek(pb, mxf->run_in + mxf->current_partition->previous_partition, SEEK_SET);
mxf->current_partition = NULL;
- av_dlog(mxf->fc, "seeking to previous partition\n");
+ av_log(mxf->fc, AV_LOG_TRACE, "seeking to previous partition\n");
return 1;
}
: mxf->last_partition;
if (!offset) {
- av_dlog(mxf->fc, "no last partition\n");
+ av_log(mxf->fc, AV_LOG_TRACE, "no last partition\n");
return 0;
}
- av_dlog(mxf->fc, "seeking to last partition\n");
+ av_log(mxf->fc, AV_LOG_TRACE, "seeking to last partition\n");
/* remember where we were so we don't end up seeking further back than this */
mxf->last_forward_tell = avio_tell(pb);
/* 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)
}
PRINT_KEY(s, "read header", klv.key);
- av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
+ av_log(s, AV_LOG_TRACE, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) ||
IS_KLV_KEY(klv.key, mxf_essence_element_key) ||
IS_KLV_KEY(klv.key, mxf_avid_essence_element_key) ||
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 || codec->channels * bits_per_sample < 8)
+ if (par->channels <= 0 || par->channels * bits_per_sample < 8)
return AVERROR_INVALIDDATA;
- track->sample_count += pkt->size / (codec->channels * bits_per_sample / 8);
+ track->sample_count += pkt->size / (par->channels * bits_per_sample / 8);
return 0;
}
if ((ret = klv_read_packet(&klv, s->pb)) < 0)
return ret;
PRINT_KEY(s, "read packet", klv.key);
- av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
+ av_log(s, AV_LOG_TRACE, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
ret = mxf_decrypt_triplet(s, pkt, &klv);
if (ret < 0) {
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 = s->streams[index]->codec;
+ par = s->streams[index]->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];
* < 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;