summaryrefslogtreecommitdiff
path: root/libavformat/mxfdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r--libavformat/mxfdec.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 40b4d79996..f8cf92283f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -405,15 +405,15 @@ static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt,
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;
@@ -1969,7 +1969,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
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);
@@ -1993,14 +1993,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
/* 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]);
@@ -2015,16 +2015,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
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. */
@@ -2035,14 +2035,14 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
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,
@@ -2052,27 +2052,27 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
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;
}
}
}
@@ -2087,16 +2087,16 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
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) "
@@ -2113,20 +2113,20 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
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 &&
@@ -2136,19 +2136,19 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
}
}
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;
}
@@ -2579,8 +2579,8 @@ static void mxf_handle_small_eubc(AVFormatContext *s)
/* 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)
@@ -2609,7 +2609,7 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf)
return 0;
/* TODO: support raw video without an 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))
+ 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 */
@@ -2643,7 +2643,7 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf)
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;
@@ -2918,22 +2918,22 @@ static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
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;
}
@@ -2961,7 +2961,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
int64_t next_ofs, next_klv;
AVStream *st;
MXFTrack *track;
- AVCodecContext *codec;
+ AVCodecParameters *par;
if (index < 0) {
av_log(s, AV_LOG_ERROR,
@@ -3006,9 +3006,9 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
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];
@@ -3021,8 +3021,8 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
* 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;
}
@@ -3088,12 +3088,12 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
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;
}
@@ -3172,7 +3172,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
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));
@@ -3231,7 +3231,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
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, &current_sample_count);
if (ret < 0)
return ret;