diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-19 22:24:33 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-19 22:46:51 +0200 |
commit | f4b05cd8415ad6160900bb00565f9b75e356530e (patch) | |
tree | a1b89b58a5fd5d3d657d8135169ad39075a891be /libavcodec/h264_ps.c | |
parent | 05b2c998c7bfea642e3541787ab5dd3847e2ba81 (diff) | |
parent | 5e83d9aced2fc2b2e1360452794c58aba55d497c (diff) | |
download | ffmpeg-f4b05cd8415ad6160900bb00565f9b75e356530e.tar.gz |
Merge commit '5e83d9aced2fc2b2e1360452794c58aba55d497c'
* commit '5e83d9aced2fc2b2e1360452794c58aba55d497c':
h264: fully support cropping.
Conflicts:
doc/APIchanges
libavcodec/h264.c
libavcodec/h264_ps.c
libavcodec/options_table.h
libavcodec/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h264_ps.c')
-rw-r--r-- | libavcodec/h264_ps.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c index 8638ce267d..68f504a360 100644 --- a/libavcodec/h264_ps.c +++ b/libavcodec/h264_ps.c @@ -459,44 +459,45 @@ int ff_h264_decode_seq_parameter_set(H264Context *h){ #endif sps->crop= get_bits1(&h->gb); if(sps->crop){ - int crop_vertical_limit = sps->chroma_format_idc & 2 ? 16 : 8; - int crop_horizontal_limit = sps->chroma_format_idc == 3 ? 16 : 8; - sps->crop_left = get_ue_golomb(&h->gb); - sps->crop_right = get_ue_golomb(&h->gb); - sps->crop_top = get_ue_golomb(&h->gb); - sps->crop_bottom= get_ue_golomb(&h->gb); + int crop_left = get_ue_golomb(&h->gb); + int crop_right = get_ue_golomb(&h->gb); + int crop_top = get_ue_golomb(&h->gb); + int crop_bottom = get_ue_golomb(&h->gb); + if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { - av_log(h->avctx, AV_LOG_DEBUG, - "discarding sps cropping, " - "original values are l:%u r:%u t:%u b:%u\n", - sps->crop_left, - sps->crop_right, - sps->crop_top, - sps->crop_bottom); + av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original " + "values are l:%u r:%u t:%u b:%u\n", crop_left, crop_right, + crop_top, crop_bottom); sps->crop_left = sps->crop_right = sps->crop_top = sps->crop_bottom = 0; - } - if(sps->crop_left || sps->crop_top){ - av_log(h->avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ... (left: %d, top: %d)\n", sps->crop_left, sps->crop_top); - } - if(sps->crop_right >= crop_horizontal_limit || sps->crop_bottom >= crop_vertical_limit){ - av_log(h->avctx, AV_LOG_ERROR, "brainfart cropping not supported, cropping disabled (right: %d, bottom: %d)\n", sps->crop_right, sps->crop_bottom); - /* It is very unlikely that partial cropping will make anybody happy. - * Not cropping at all fixes for example playback of Sisvel 3D streams - * in applications supporting Sisvel 3D. */ - sps->crop_left = - sps->crop_right = - sps->crop_top = - sps->crop_bottom= 0; + } else { + int vsub = (sps->chroma_format_idc == 1) ? 1 : 0; + int hsub = (sps->chroma_format_idc == 1 || sps->chroma_format_idc == 2) ? 1 : 0; + int step_x = 1 << hsub; + int step_y = (2 - sps->frame_mbs_only_flag) << vsub; + + if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) && + !(h->avctx->flags & CODEC_FLAG_UNALIGNED)) { + crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8)); + av_log(h->avctx, AV_LOG_WARNING, "Reducing left cropping to %d " + "chroma samples to preserve alignment.\n", + crop_left); + } + + sps->crop_left = crop_left * step_x; + sps->crop_right = crop_right * step_x; + sps->crop_top = crop_top * step_y; + sps->crop_bottom = crop_bottom * step_y; } }else{ sps->crop_left = sps->crop_right = sps->crop_top = sps->crop_bottom= 0; + sps->crop = 0; } sps->vui_parameters_present_flag= get_bits1(&h->gb); |