---
 libavcodec/h264_ps.c    |  9 ---------
 libavcodec/h264_slice.c |  7 +++++--
 libavcodec/h264dec.c    | 24 ++----------------------
 3 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 8a64a33..7ee3876 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -498,15 +498,6 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, 
AVCodecContext *avctx,
             int step_x = 1 << hsub;
             int step_y = (2 - sps->frame_mbs_only_flag) << vsub;
 
-            if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&
-                !(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) {
-                crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));
-                av_log(avctx, AV_LOG_WARNING,
-                       "Reducing left cropping to %d "
-                       "chroma samples to preserve alignment.\n",
-                       crop_left);
-            }
-
             if (INT_MAX / step_x             <= crop_left               ||
                 INT_MAX / step_x - crop_left <= crop_right              ||
                 16 * sps->mb_width <= step_x * (crop_left + crop_right) ||
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 1b91088..ff963c2 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -471,6 +471,9 @@ static int h264_frame_start(H264Context *h)
 
     pic->f->pict_type = h->slice_ctx[0].slice_type;
 
+    pic->f->crop_left = h->ps.sps->crop_left;
+    pic->f->crop_top  = h->ps.sps->crop_top;
+
     if (CONFIG_ERROR_RESILIENCE && h->enable_er)
         ff_er_frame_start(&h->slice_ctx[0].er);
 
@@ -793,8 +796,8 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
 static int init_dimensions(H264Context *h)
 {
     SPS *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 width  = h->width  - sps->crop_left;
+    int height = h->height - sps->crop_bottom;
 
     /* handle container cropping */
     if (FFALIGN(h->avctx->width,  16) == FFALIGN(width,  16) &&
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 330a74d..e92a915 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -658,26 +658,6 @@ static int get_consumed_bytes(int pos, int buf_size)
     return pos;
 }
 
-static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src)
-{
-    int i;
-    int ret = av_frame_ref(dst, src);
-    if (ret < 0)
-        return ret;
-
-    if (!h->ps.sps || !h->ps.sps->crop)
-        return 0;
-
-    for (i = 0; i < 3; i++) {
-        int hshift = (i > 0) ? h->chroma_x_shift : 0;
-        int vshift = (i > 0) ? h->chroma_y_shift : 0;
-        int off    = ((h->ps.sps->crop_left >> hshift) << h->pixel_shift) +
-                     (h->ps.sps->crop_top >> vshift) * dst->linesize[i];
-        dst->data[i] += off;
-    }
-    return 0;
-}
-
 static int h264_decode_frame(AVCodecContext *avctx, void *data,
                              int *got_frame, AVPacket *avpkt)
 {
@@ -719,7 +699,7 @@ out:
             h->delayed_pic[i] = h->delayed_pic[i + 1];
 
         if (out) {
-            ret = output_frame(h, pict, out->f);
+            ret = av_frame_ref(pict, out->f);
             if (ret < 0)
                 return ret;
             *got_frame = 1;
@@ -761,7 +741,7 @@ out:
 
         *got_frame = 0;
         if (h->output_frame->buf[0]) {
-            ret = output_frame(h, pict, h->output_frame) ;
+            ret = av_frame_ref(pict, h->output_frame);
             av_frame_unref(h->output_frame);
             if (ret < 0)
                 return ret;
-- 
2.0.0

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to