diff options
author | Marton Balint <cus@passwd.hu> | 2014-06-14 17:07:27 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-14 19:45:53 +0200 |
commit | 66f4891e6422ada894dccdd63bc4464d634d9e61 (patch) | |
tree | 4ebfdcdac53804a6009a98ebca1a0b22e29382b3 /libavcodec/mpeg12enc.c | |
parent | 6ac3c8c6a0c6c69b84e408a9b494fcb26294b9ee (diff) | |
download | ffmpeg-66f4891e6422ada894dccdd63bc4464d634d9e61.tar.gz |
mpeg12enc: add support for PANSCAN side data in sequence_display_extension
Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpeg12enc.c')
-rw-r--r-- | libavcodec/mpeg12enc.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index cb7c367848..4fb9c447f3 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -311,6 +311,11 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) ff_write_quant_matrix(&s->pb, s->avctx->inter_matrix); if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { + AVFrameSideData *side_data; + int width = s->width; + int height = s->height; + int use_seq_disp_ext; + put_header(s, EXT_START_CODE); put_bits(&s->pb, 4, 1); // seq ext @@ -330,9 +335,22 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) put_bits(&s->pb, 2, s->mpeg2_frame_rate_ext.num-1); // frame_rate_ext_n put_bits(&s->pb, 5, s->mpeg2_frame_rate_ext.den-1); // frame_rate_ext_d - if (s->avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || - s->avctx->color_trc != AVCOL_TRC_UNSPECIFIED || - s->avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { + side_data = av_frame_get_side_data(s->current_picture_ptr->f, AV_FRAME_DATA_PANSCAN); + if (side_data) { + AVPanScan *pan_scan = (AVPanScan *)side_data->data; + if (pan_scan->width && pan_scan->height) { + width = pan_scan->width >> 4; + height = pan_scan->height >> 4; + } + } + + use_seq_disp_ext = (width != s->width || + height != s->height || + s->avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || + s->avctx->color_trc != AVCOL_TRC_UNSPECIFIED || + s->avctx->colorspace != AVCOL_SPC_UNSPECIFIED); + + if (use_seq_disp_ext) { put_header(s, EXT_START_CODE); put_bits(&s->pb, 4, 2); // sequence display extension put_bits(&s->pb, 3, 0); // video_format: 0 is components @@ -340,9 +358,9 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s) put_bits(&s->pb, 8, s->avctx->color_primaries); // colour_primaries put_bits(&s->pb, 8, s->avctx->color_trc); // transfer_characteristics put_bits(&s->pb, 8, s->avctx->colorspace); // matrix_coefficients - put_bits(&s->pb, 14, s->width); // display_horizontal_size + put_bits(&s->pb, 14, width); // display_horizontal_size put_bits(&s->pb, 1, 1); // marker_bit - put_bits(&s->pb, 14, s->height); // display_vertical_size + put_bits(&s->pb, 14, height); // display_vertical_size put_bits(&s->pb, 3, 0); // remaining 3 bits are zero padding } } |