aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskadec.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:58:15 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-04-10 20:59:55 +0100
commit6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch)
tree0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/matroskadec.c
parent60b75186b2c878b6257b43c8fcc0b1356ada218e (diff)
parent9200514ad8717c63f82101dc394f4378854325bf (diff)
downloadffmpeg-6f69f7a8bf6a0d013985578df2ef42ee6b1c7994.tar.gz
Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r--libavformat/matroskadec.c141
1 files changed, 70 insertions, 71 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 28bb77b4ae..fa301a7900 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1737,7 +1737,7 @@ static int matroska_parse_flac(AVFormatContext *s,
av_log(s, AV_LOG_WARNING,
"Invalid value of WAVEFORMATEXTENSIBLE_CHANNEL_MASK\n");
} else
- st->codec->channel_layout = mask;
+ st->codecpar->channel_layout = mask;
}
av_dict_free(&dict);
}
@@ -1785,14 +1785,14 @@ static int mkv_parse_video_color(AVStream *st, const MatroskaTrack *track) {
const int has_mastering_luminance = mastering_meta->max_luminance > 0;
if (track->video.color.matrix_coefficients != AVCOL_SPC_RESERVED)
- st->codec->colorspace = track->video.color.matrix_coefficients;
+ st->codecpar->color_space = track->video.color.matrix_coefficients;
if (track->video.color.primaries != AVCOL_PRI_RESERVED)
- st->codec->color_primaries = track->video.color.primaries;
+ st->codecpar->color_primaries = track->video.color.primaries;
if (track->video.color.transfer_characteristics != AVCOL_TRC_RESERVED)
- st->codec->color_trc = track->video.color.transfer_characteristics;
+ st->codecpar->color_trc = track->video.color.transfer_characteristics;
if (track->video.color.range != AVCOL_RANGE_UNSPECIFIED &&
track->video.color.range <= AVCOL_RANGE_JPEG)
- st->codec->color_range = track->video.color.range;
+ st->codecpar->color_range = track->video.color.range;
if (has_mastering_primaries || has_mastering_luminance) {
// Use similar rationals as other standards.
@@ -2009,11 +2009,11 @@ static int matroska_parse_tracks(AVFormatContext *s)
ffio_init_context(&b, track->codec_priv.data,
track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
- ret = ff_get_wav_header(s, &b, st->codec, track->codec_priv.size, 0);
+ ret = ff_get_wav_header(s, &b, st->codecpar, track->codec_priv.size, 0);
if (ret < 0)
return ret;
- codec_id = st->codec->codec_id;
- fourcc = st->codec->codec_tag;
+ codec_id = st->codecpar->codec_id;
+ fourcc = st->codecpar->codec_tag;
extradata_offset = FFMIN(track->codec_priv.size, 18);
} else if (!strcmp(track->codec_id, "A_QUICKTIME")
/* Normally 36, but allow noncompliant private data */
@@ -2185,15 +2185,15 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (!track->audio.buf)
return AVERROR(ENOMEM);
if (codec_id == AV_CODEC_ID_RA_288) {
- st->codec->block_align = track->audio.coded_framesize;
+ st->codecpar->block_align = track->audio.coded_framesize;
track->codec_priv.size = 0;
} else {
if (codec_id == AV_CODEC_ID_SIPR && flavor < 4) {
static const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
- st->codec->bit_rate = sipr_bit_rate[flavor];
+ st->codecpar->bit_rate = sipr_bit_rate[flavor];
}
- st->codec->block_align = track->audio.sub_packet_size;
+ st->codecpar->block_align = track->audio.sub_packet_size;
extradata_offset = 78;
}
} else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) {
@@ -2219,7 +2219,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
(AVRational){ 1, 1000000000 },
st->time_base);
- st->codec->codec_id = codec_id;
+ st->codecpar->codec_id = codec_id;
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
@@ -2230,14 +2230,14 @@ static int matroska_parse_tracks(AVFormatContext *s)
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
- if (!st->codec->extradata) {
+ if (!st->codecpar->extradata) {
if (extradata) {
- st->codec->extradata = extradata;
- st->codec->extradata_size = extradata_size;
+ st->codecpar->extradata = extradata;
+ st->codecpar->extradata_size = extradata_size;
} else if (track->codec_priv.data && track->codec_priv.size > 0) {
- if (ff_alloc_extradata(st->codec, track->codec_priv.size))
+ if (ff_alloc_extradata(st->codecpar, track->codec_priv.size))
return AVERROR(ENOMEM);
- memcpy(st->codec->extradata,
+ memcpy(st->codecpar->extradata,
track->codec_priv.data + extradata_offset,
track->codec_priv.size);
}
@@ -2248,22 +2248,22 @@ static int matroska_parse_tracks(AVFormatContext *s)
int display_width_mul = 1;
int display_height_mul = 1;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->codec_tag = fourcc;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codecpar->codec_tag = fourcc;
if (bit_depth >= 0)
- st->codec->bits_per_coded_sample = bit_depth;
- st->codec->width = track->video.pixel_width;
- st->codec->height = track->video.pixel_height;
+ st->codecpar->bits_per_coded_sample = bit_depth;
+ st->codecpar->width = track->video.pixel_width;
+ st->codecpar->height = track->video.pixel_height;
if (track->video.stereo_mode && track->video.stereo_mode < MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
mkv_stereo_mode_display_mul(track->video.stereo_mode, &display_width_mul, &display_height_mul);
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
- st->codec->height * track->video.display_width * display_width_mul,
- st->codec->width * track->video.display_height * display_height_mul,
+ st->codecpar->height * track->video.display_width * display_width_mul,
+ st->codecpar->width * track->video.display_height * display_height_mul,
255);
- if (st->codec->codec_id != AV_CODEC_ID_HEVC)
+ if (st->codecpar->codec_id != AV_CODEC_ID_HEVC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->default_duration) {
@@ -2312,29 +2312,28 @@ static int matroska_parse_tracks(AVFormatContext *s)
return ret;
}
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- st->codec->codec_tag = fourcc;
- st->codec->sample_rate = track->audio.out_samplerate;
- st->codec->channels = track->audio.channels;
- if (!st->codec->bits_per_coded_sample)
- st->codec->bits_per_coded_sample = track->audio.bitdepth;
- if (st->codec->codec_id == AV_CODEC_ID_MP3)
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_tag = fourcc;
+ st->codecpar->sample_rate = track->audio.out_samplerate;
+ st->codecpar->channels = track->audio.channels;
+ if (!st->codecpar->bits_per_coded_sample)
+ st->codecpar->bits_per_coded_sample = track->audio.bitdepth;
+ if (st->codecpar->codec_id == AV_CODEC_ID_MP3)
st->need_parsing = AVSTREAM_PARSE_FULL;
- else if (st->codec->codec_id != AV_CODEC_ID_AAC)
+ else if (st->codecpar->codec_id != AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->codec_delay > 0) {
- st->codec->delay = av_rescale_q(track->codec_delay,
- st->time_base,
- (AVRational){1, st->codec->sample_rate});
+ st->codecpar->initial_padding = av_rescale_q(track->codec_delay,
+ st->time_base,
+ (AVRational){1, st->codecpar->sample_rate});
}
if (track->seek_preroll > 0) {
- av_codec_set_seek_preroll(st->codec,
- av_rescale_q(track->seek_preroll,
- (AVRational){1, 1000000000},
- (AVRational){1, st->codec->sample_rate}));
+ st->codecpar->seek_preroll = av_rescale_q(track->seek_preroll,
+ (AVRational){1, 1000000000},
+ (AVRational){1, st->codecpar->sample_rate});
}
} else if (codec_id == AV_CODEC_ID_WEBVTT) {
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (!strcmp(track->codec_id, "D_WEBVTT/CAPTIONS")) {
st->disposition |= AV_DISPOSITION_CAPTIONS;
@@ -2344,8 +2343,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
st->disposition |= AV_DISPOSITION_METADATA;
}
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- if (st->codec->codec_id == AV_CODEC_ID_ASS)
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ if (st->codecpar->codec_id == AV_CODEC_ID_ASS)
matroska->contains_ssa = 1;
}
}
@@ -2441,21 +2440,21 @@ static int matroska_read_header(AVFormatContext *s)
break;
av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
- st->codec->codec_id = AV_CODEC_ID_NONE;
+ st->codecpar->codec_id = AV_CODEC_ID_NONE;
for (i = 0; ff_mkv_image_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_image_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_image_mime_tags[i].str))) {
- st->codec->codec_id = ff_mkv_image_mime_tags[i].id;
+ st->codecpar->codec_id = ff_mkv_image_mime_tags[i].id;
break;
}
}
attachments[j].stream = st;
- if (st->codec->codec_id != AV_CODEC_ID_NONE) {
- st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ if (st->codecpar->codec_id != AV_CODEC_ID_NONE) {
+ st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
av_init_packet(&st->attached_pic);
if ((res = av_new_packet(&st->attached_pic, attachments[j].bin.size)) < 0)
@@ -2464,16 +2463,16 @@ static int matroska_read_header(AVFormatContext *s)
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
- st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
- if (ff_alloc_extradata(st->codec, attachments[j].bin.size))
+ st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
+ if (ff_alloc_extradata(st->codecpar, attachments[j].bin.size))
break;
- memcpy(st->codec->extradata, attachments[j].bin.data,
+ memcpy(st->codecpar->extradata, attachments[j].bin.data,
attachments[j].bin.size);
for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
strlen(ff_mkv_mime_tags[i].str))) {
- st->codec->codec_id = ff_mkv_mime_tags[i].id;
+ st->codecpar->codec_id = ff_mkv_mime_tags[i].id;
break;
}
}
@@ -2677,7 +2676,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
uint8_t *data, int size, uint64_t timecode,
int64_t pos)
{
- int a = st->codec->block_align;
+ int a = st->codecpar->block_align;
int sps = track->audio.sub_packet_size;
int cfs = track->audio.coded_framesize;
int h = track->audio.sub_packet_h;
@@ -2688,7 +2687,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
if (!track->audio.pkt_cnt) {
if (track->audio.sub_packet_cnt == 0)
track->audio.buf_timecode = timecode;
- if (st->codec->codec_id == AV_CODEC_ID_RA_288) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_RA_288) {
if (size < cfs * h / 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt int4 RM-style audio packet size\n");
@@ -2697,7 +2696,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
for (x = 0; x < h / 2; x++)
memcpy(track->audio.buf + x * 2 * w + y * cfs,
data + x * cfs, cfs);
- } else if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_SIPR) {
if (size < w) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Corrupt sipr RM-style audio packet size\n");
@@ -2717,7 +2716,7 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
}
if (++track->audio.sub_packet_cnt >= h) {
- if (st->codec->codec_id == AV_CODEC_ID_SIPR)
+ if (st->codecpar->codec_id == AV_CODEC_ID_SIPR)
ff_rm_reorder_sipr_data(track->audio.buf, h, w);
track->audio.sub_packet_cnt = 0;
track->audio.pkt_cnt = h * w / a;
@@ -2759,10 +2758,10 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
uint16_t ver;
int ret, offset = 0;
- if (srclen < 12 || track->stream->codec->extradata_size < 2)
+ if (srclen < 12 || track->stream->codecpar->extradata_size < 2)
return AVERROR_INVALIDDATA;
- ver = AV_RL16(track->stream->codec->extradata);
+ ver = AV_RL16(track->stream->codecpar->extradata);
samples = AV_RL32(src);
src += 4;
@@ -2964,7 +2963,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
return res;
}
- if (st->codec->codec_id == AV_CODEC_ID_WAVPACK) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_WAVPACK) {
uint8_t *wv_data;
res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);
if (res < 0) {
@@ -2977,7 +2976,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
pkt_data = wv_data;
}
- if (st->codec->codec_id == AV_CODEC_ID_PRORES &&
+ if (st->codecpar->codec_id == AV_CODEC_ID_PRORES &&
AV_RB32(&data[4]) != MKBETAG('i', 'c', 'p', 'f'))
offset = 8;
@@ -2994,7 +2993,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
goto fail;
}
- if (st->codec->codec_id == AV_CODEC_ID_PRORES && offset == 8) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_PRORES && offset == 8) {
uint8_t *buf = pkt->data;
bytestream_put_be32(&buf, pkt_size);
bytestream_put_be32(&buf, MKBETAG('i', 'c', 'p', 'f'));
@@ -3033,7 +3032,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
AV_WL32(side_data, 0);
AV_WL32(side_data + 4, av_rescale_q(discard_padding,
(AVRational){1, 1000000000},
- (AVRational){1, st->codec->sample_rate}));
+ (AVRational){1, st->codecpar->sample_rate}));
}
if (track->ms_compat)
@@ -3045,7 +3044,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
- if (st->codec->codec_id == AV_CODEC_ID_SUBRIP) {
+ if (st->codecpar->codec_id == AV_CODEC_ID_SUBRIP) {
pkt->convergence_duration = lace_duration;
}
FF_ENABLE_DEPRECATION_WARNINGS
@@ -3135,8 +3134,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
if (track->audio.samplerate == 8000) {
// If this is needed for more codecs, then add them here
- if (st->codec->codec_id == AV_CODEC_ID_AC3) {
- if (track->audio.samplerate != st->codec->sample_rate || !st->codec->frame_size)
+ if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+ if (track->audio.samplerate != st->codecpar->sample_rate || !st->codecpar->frame_size)
trust_default_duration = 0;
}
}
@@ -3156,18 +3155,18 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
break;
}
- if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
- st->codec->codec_id == AV_CODEC_ID_COOK ||
- st->codec->codec_id == AV_CODEC_ID_SIPR ||
- st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
- st->codec->block_align && track->audio.sub_packet_size) {
+ if ((st->codecpar->codec_id == AV_CODEC_ID_RA_288 ||
+ st->codecpar->codec_id == AV_CODEC_ID_COOK ||
+ st->codecpar->codec_id == AV_CODEC_ID_SIPR ||
+ st->codecpar->codec_id == AV_CODEC_ID_ATRAC3) &&
+ st->codecpar->block_align && track->audio.sub_packet_size) {
res = matroska_parse_rm_audio(matroska, track, st, data,
lace_size[n],
timecode, pos);
if (res)
goto end;
- } else if (st->codec->codec_id == AV_CODEC_ID_WEBVTT) {
+ } else if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) {
res = matroska_parse_webvtt(matroska, track, st,
data, lace_size[n],
timecode, lace_duration,