mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-03 14:32:16 +02:00
avcodec/h264dec: be more explicit in handling container cropping
This merges commit 4fded0480f20f4d7ca5e776a85574de34dfead14 from libav, originally written by Anton Khirnov and skipped in fc63d5ceb357c4b760cb02772de0b50d0557140f. libavcodec/h264_slice.c | 20 +++++++++++++------- libavcodec/h264dec.c | 3 +++ libavcodec/h264dec.h | 5 +++++ 3 files changed, 21 insertions(+), 7 deletions(-)
This commit is contained in:
parent
000fb61a71
commit
6505e8cfd0
@ -378,6 +378,8 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
|
|||||||
h->avctx->coded_width = h1->avctx->coded_width;
|
h->avctx->coded_width = h1->avctx->coded_width;
|
||||||
h->avctx->width = h1->avctx->width;
|
h->avctx->width = h1->avctx->width;
|
||||||
h->avctx->height = h1->avctx->height;
|
h->avctx->height = h1->avctx->height;
|
||||||
|
h->width_from_caller = h1->width_from_caller;
|
||||||
|
h->height_from_caller = h1->height_from_caller;
|
||||||
h->coded_picture_number = h1->coded_picture_number;
|
h->coded_picture_number = h1->coded_picture_number;
|
||||||
h->first_field = h1->first_field;
|
h->first_field = h1->first_field;
|
||||||
h->picture_structure = h1->picture_structure;
|
h->picture_structure = h1->picture_structure;
|
||||||
@ -874,13 +876,17 @@ static int init_dimensions(H264Context *h)
|
|||||||
av_assert0(sps->crop_top + sps->crop_bottom < (unsigned)h->height);
|
av_assert0(sps->crop_top + sps->crop_bottom < (unsigned)h->height);
|
||||||
|
|
||||||
/* handle container cropping */
|
/* handle container cropping */
|
||||||
if (FFALIGN(h->avctx->width, 16) == FFALIGN(width, 16) &&
|
if (h->width_from_caller > 0 && h->height_from_caller > 0 &&
|
||||||
FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16) &&
|
!sps->crop_top && !sps->crop_left &&
|
||||||
h->avctx->width <= width &&
|
FFALIGN(h->width_from_caller, 16) == FFALIGN(width, 16) &&
|
||||||
h->avctx->height <= height
|
FFALIGN(h->height_from_caller, 16) == FFALIGN(height, 16) &&
|
||||||
) {
|
h->width_from_caller <= width &&
|
||||||
width = h->avctx->width;
|
h->height_from_caller <= height) {
|
||||||
height = h->avctx->height;
|
width = h->width_from_caller;
|
||||||
|
height = h->height_from_caller;
|
||||||
|
} else {
|
||||||
|
h->width_from_caller = 0;
|
||||||
|
h->height_from_caller = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h->avctx->coded_width = h->width;
|
h->avctx->coded_width = h->width;
|
||||||
|
@ -309,6 +309,9 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h)
|
|||||||
h->avctx = avctx;
|
h->avctx = avctx;
|
||||||
h->cur_chroma_format_idc = -1;
|
h->cur_chroma_format_idc = -1;
|
||||||
|
|
||||||
|
h->width_from_caller = avctx->width;
|
||||||
|
h->height_from_caller = avctx->height;
|
||||||
|
|
||||||
h->picture_structure = PICT_FRAME;
|
h->picture_structure = PICT_FRAME;
|
||||||
h->workaround_bugs = avctx->workaround_bugs;
|
h->workaround_bugs = avctx->workaround_bugs;
|
||||||
h->flags = avctx->flags;
|
h->flags = avctx->flags;
|
||||||
|
@ -534,6 +534,11 @@ typedef struct H264Context {
|
|||||||
int cur_bit_depth_luma;
|
int cur_bit_depth_luma;
|
||||||
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
|
int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
|
||||||
|
|
||||||
|
/* original AVCodecContext dimensions, used to handle container
|
||||||
|
* cropping */
|
||||||
|
int width_from_caller;
|
||||||
|
int height_from_caller;
|
||||||
|
|
||||||
int enable_er;
|
int enable_er;
|
||||||
|
|
||||||
H264SEIContext sei;
|
H264SEIContext sei;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user