summaryrefslogtreecommitdiff
path: root/libavcodec/h264_slice.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-05-08 15:46:24 -0300
committerJames Almer <jamrial@gmail.com>2017-05-26 11:15:45 -0300
commit07596e45c5a0195b6e4e57597497ec7066817739 (patch)
treec4fa896c8d8042d0f10d87c9ba04725458faf302 /libavcodec/h264_slice.c
parent6505e8cfd02b9112e24bb40c145d6c760f15d622 (diff)
avcodec/h264dec: export cropping information instead of handling it internally
This merges commit c3e84820d67cb1d8cfb4196f9b43971308a81571 from libav, originally written by Anton Khirnov and skipped in fc63d5ceb357c4b760cb02772de0b50d0557140f. libavcodec/h264_picture.c | 3 --- libavcodec/h264_ps.c | 9 --------- libavcodec/h264_slice.c | 25 +++++++++++++++++++------ libavcodec/h264dec.c | 13 +------------ libavcodec/h264dec.h | 9 +++++---- 5 files changed, 25 insertions(+), 34 deletions(-)
Diffstat (limited to 'libavcodec/h264_slice.c')
-rw-r--r--libavcodec/h264_slice.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a7916e09ce..8ba23712a1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -197,10 +197,6 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
if (ret < 0)
goto fail;
- pic->crop = h->ps.sps->crop;
- pic->crop_top = h->ps.sps->crop_top;
- pic->crop_left= h->ps.sps->crop_left;
-
if (h->avctx->hwaccel) {
const AVHWAccel *hwaccel = h->avctx->hwaccel;
av_assert0(!pic->hwaccel_picture_private);
@@ -495,6 +491,11 @@ static int h264_frame_start(H264Context *h)
pic->f->pict_type = h->slice_ctx[0].slice_type;
+ pic->f->crop_left = h->crop_left;
+ pic->f->crop_right = h->crop_right;
+ pic->f->crop_top = h->crop_top;
+ pic->f->crop_bottom = h->crop_bottom;
+
if ((ret = alloc_picture(h, pic)) < 0)
return ret;
if(!h->frame_recovered && !h->avctx->hwaccel
@@ -870,8 +871,12 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
static int init_dimensions(H264Context *h)
{
const SPS *sps = (const SPS*)h->ps.sps;
- int width = h->width - (sps->crop_right + sps->crop_left);
- int height = h->height - (sps->crop_top + sps->crop_bottom);
+ int cr = sps->crop_right;
+ int cl = sps->crop_left;
+ int ct = sps->crop_top;
+ int cb = sps->crop_bottom;
+ int width = h->width - (cr + cl);
+ int height = h->height - (ct + cb);
av_assert0(sps->crop_right + sps->crop_left < (unsigned)h->width);
av_assert0(sps->crop_top + sps->crop_bottom < (unsigned)h->height);
@@ -884,6 +889,10 @@ static int init_dimensions(H264Context *h)
h->height_from_caller <= height) {
width = h->width_from_caller;
height = h->height_from_caller;
+ cl = 0;
+ ct = 0;
+ cr = h->width - width;
+ cb = h->height - height;
} else {
h->width_from_caller = 0;
h->height_from_caller = 0;
@@ -893,6 +902,10 @@ static int init_dimensions(H264Context *h)
h->avctx->coded_height = h->height;
h->avctx->width = width;
h->avctx->height = height;
+ h->crop_right = cr;
+ h->crop_left = cl;
+ h->crop_top = ct;
+ h->crop_bottom = cb;
return 0;
}