Commit 074bae74 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ecf442a5'

* commit 'ecf442a5':
  lavf: improve support for AVC-Intra files.

Conflicts:
	libavformat/internal.h
	libavformat/isom.c
	libavformat/mxfdec.c
	libavformat/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 0f969c00 ecf442a5
......@@ -357,9 +357,10 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precission);
/**
* Generate standard extradata for AVC-Intra based on width/height and field order.
* Generate standard extradata for AVC-Intra based on width/height and field
* order.
*/
void ff_generate_avci_extradata(AVStream *st);
int ff_generate_avci_extradata(AVStream *st);
/**
* Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end
......
......@@ -207,6 +207,22 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
#define MOV_TKHD_FLAG_IN_PREVIEW 0x0004
#define MOV_TKHD_FLAG_IN_POSTER 0x0008
#define TAG_IS_AVCI(tag) \
((tag) == MKTAG('a', 'i', '5', 'p') || \
(tag) == MKTAG('a', 'i', '5', 'q') || \
(tag) == MKTAG('a', 'i', '5', '2') || \
(tag) == MKTAG('a', 'i', '5', '3') || \
(tag) == MKTAG('a', 'i', '5', '5') || \
(tag) == MKTAG('a', 'i', '5', '6') || \
(tag) == MKTAG('a', 'i', '1', 'p') || \
(tag) == MKTAG('a', 'i', '1', 'q') || \
(tag) == MKTAG('a', 'i', '1', '2') || \
(tag) == MKTAG('a', 'i', '1', '3') || \
(tag) == MKTAG('a', 'i', '1', '5') || \
(tag) == MKTAG('a', 'i', '1', '6') || \
(tag) == MKTAG('A', 'V', 'i', 'n'))
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom);
enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags);
......
......@@ -2387,8 +2387,10 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
// done for ai5q, ai52, ai55, ai1q, ai12 and ai15.
if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 &&
st->codec->codec_tag != MKTAG('a', 'v', 'c', '1')) {
ff_generate_avci_extradata(st);
TAG_IS_AVCI(st->codec->codec_tag)) {
ret = ff_generate_avci_extradata(st);
if (ret < 0)
return ret;
}
switch (st->codec->codec_id) {
......
......@@ -1516,6 +1516,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
av_log(mxf->fc, AV_LOG_VERBOSE, ".");
}
av_log(mxf->fc, AV_LOG_VERBOSE, "\n");
if (st->codec->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);
......@@ -1605,8 +1606,10 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
if (!ff_alloc_extradata(st->codec, descriptor->extradata_size)) {
memcpy(st->codec->extradata, descriptor->extradata, descriptor->extradata_size);
}
} else if(st->codec->codec_id == AV_CODEC_ID_H264) {
ff_generate_avci_extradata(st);
} else if (st->codec->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) {
/* TODO: decode timestamps */
......
......@@ -4171,7 +4171,7 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
return AVERROR(EINVAL);
}
void ff_generate_avci_extradata(AVStream *st)
int ff_generate_avci_extradata(AVStream *st)
{
static const uint8_t avci100_1080p_extradata[] = {
// SPS
......@@ -4238,8 +4238,10 @@ void ff_generate_avci_extradata(AVStream *st)
0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
0x11
};
const uint8_t *data = NULL;
int size = 0;
const uint8_t *data = 0;
if (st->codec->width == 1920) {
if (st->codec->field_order == AV_FIELD_PROGRESSIVE) {
data = avci100_1080p_extradata;
......@@ -4255,10 +4257,14 @@ void ff_generate_avci_extradata(AVStream *st)
data = avci100_720p_extradata;
size = sizeof(avci100_720p_extradata);
}
if (!size)
return;
return 0;
av_freep(&st->codec->extradata);
if (ff_alloc_extradata(st->codec, size))
return;
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, data, size);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment