diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:58:15 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-10 20:59:55 +0100 |
commit | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 (patch) | |
tree | 0c2ec8349ff1763d5f48454b8b9f26374dbd80b0 /libavformat/yuv4mpegenc.c | |
parent | 60b75186b2c878b6257b43c8fcc0b1356ada218e (diff) | |
parent | 9200514ad8717c63f82101dc394f4378854325bf (diff) | |
download | ffmpeg-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/yuv4mpegenc.c')
-rw-r--r-- | libavformat/yuv4mpegenc.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c index 033badb0af..b4dc6e9ef6 100644 --- a/libavformat/yuv4mpegenc.c +++ b/libavformat/yuv4mpegenc.c @@ -33,10 +33,12 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) int raten, rated, aspectn, aspectd, n; char inter; const char *colorspace = ""; + int field_order; st = s->streams[0]; - width = st->codec->width; - height = st->codec->height; + width = st->codecpar->width; + height = st->codecpar->height; + field_order = st->codecpar->field_order; // TODO: should be avg_frame_rate av_reduce(&raten, &rated, st->time_base.den, @@ -48,7 +50,14 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) if (aspectn == 0 && aspectd == 1) aspectd = 0; // 0:0 means unknown - switch (st->codec->field_order) { +#if FF_API_LAVF_AVCTX + FF_DISABLE_DEPRECATION_WARNINGS + if (field_order != st->codec->field_order && st->codec->field_order != AV_FIELD_UNKNOWN) + field_order = st->codec->field_order; + FF_ENABLE_DEPRECATION_WARNINGS +#endif + + switch (field_order) { case AV_FIELD_TB: case AV_FIELD_TT: inter = 't'; break; case AV_FIELD_BT: @@ -56,7 +65,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) default: inter = 'p'; break; } - switch (st->codec->pix_fmt) { + switch (st->codecpar->format) { case AV_PIX_FMT_GRAY8: colorspace = " Cmono"; break; @@ -67,7 +76,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) colorspace = " C411 XYSCSS=411"; break; case AV_PIX_FMT_YUV420P: - switch (st->codec->chroma_sample_location) { + switch (st->codecpar->chroma_location) { case AVCHROMA_LOC_TOPLEFT: colorspace = " C420paldv XYSCSS=420PALDV"; break; case AVCHROMA_LOC_LEFT: colorspace = " C420mpeg2 XYSCSS=420MPEG2"; break; default: colorspace = " C420jpeg XYSCSS=420JPEG"; break; @@ -163,12 +172,12 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC); - width = st->codec->width; - height = st->codec->height; + width = st->codecpar->width; + height = st->codecpar->height; ptr = frame->data[0]; - switch (st->codec->pix_fmt) { + switch (st->codecpar->format) { case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV411P: case AV_PIX_FMT_YUV420P: @@ -195,7 +204,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) break; default: av_log(s, AV_LOG_ERROR, "The pixel format '%s' is not supported.\n", - av_get_pix_fmt_name(st->codec->pix_fmt)); + av_get_pix_fmt_name(st->codecpar->format)); return AVERROR(EINVAL); } @@ -204,10 +213,10 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) ptr += frame->linesize[0]; } - if (st->codec->pix_fmt != AV_PIX_FMT_GRAY8 && - st->codec->pix_fmt != AV_PIX_FMT_GRAY16) { + if (st->codecpar->format != AV_PIX_FMT_GRAY8 && + st->codecpar->format != AV_PIX_FMT_GRAY16) { // Adjust for smaller Cb and Cr planes - av_pix_fmt_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, + av_pix_fmt_get_chroma_sub_sample(st->codecpar->format, &h_chroma_shift, &v_chroma_shift); // Shift right, rounding up width = AV_CEIL_RSHIFT(width, h_chroma_shift); @@ -235,12 +244,12 @@ static int yuv4_write_header(AVFormatContext *s) if (s->nb_streams != 1) return AVERROR(EIO); - if (s->streams[0]->codec->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { + if (s->streams[0]->codecpar->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME) { av_log(s, AV_LOG_ERROR, "ERROR: Codec not supported.\n"); return AVERROR_INVALIDDATA; } - switch (s->streams[0]->codec->pix_fmt) { + switch (s->streams[0]->codecpar->format) { case AV_PIX_FMT_YUV411P: av_log(s, AV_LOG_WARNING, "Warning: generating rarely used 4:1:1 YUV " "stream, some mjpegtools might not work.\n"); @@ -269,7 +278,7 @@ static int yuv4_write_header(AVFormatContext *s) if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { av_log(s, AV_LOG_ERROR, "'%s' is not an official yuv4mpegpipe pixel format. " "Use '-strict -1' to encode to this pixel format.\n", - av_get_pix_fmt_name(s->streams[0]->codec->pix_fmt)); + av_get_pix_fmt_name(s->streams[0]->codecpar->format)); return AVERROR(EINVAL); } av_log(s, AV_LOG_WARNING, "Warning: generating non standard YUV stream. " |