[libav-devel] [PATCH 4/6] hevc: change the stride of the MC buffer to be in bytes instead of elements

Anton Khirnov anton at khirnov.net
Wed Nov 18 14:28:44 CET 2015


Currently, the frame stride is passed in bytes, while the MC buffer size
is in int16_t elements, This can be confusing, so pass both strides in
bytes.
---
 libavcodec/hevc.c             |  2 +-
 libavcodec/hevcdsp_template.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index e46171e..cdb8eae 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -1666,7 +1666,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
     RefPicList  *refPicList = s->ref->refPicList;
     HEVCFrame *ref0, *ref1;
 
-    int tmpstride = MAX_PB_SIZE;
+    int tmpstride = MAX_PB_SIZE * sizeof(int16_t);
 
     uint8_t *dst0 = POS(0, x0, y0);
     uint8_t *dst1 = POS(1, x0, y0);
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index df570f3..8bb0a57 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -785,6 +785,7 @@ FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
     pixel *src          = (pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
 
+    dststride /= sizeof(*dst);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = src[x] << (14 - BIT_DEPTH);
@@ -832,6 +833,7 @@ static void FUNC(put_hevc_qpel_h ## H)(int16_t *dst,  ptrdiff_t dststride,     \
     pixel *src = (pixel*)_src;                                                 \
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);                          \
                                                                                \
+    dststride /= sizeof(*dst);                                                 \
     for (y = 0; y < height; y++) {                                             \
         for (x = 0; x < width; x++)                                            \
             dst[x] = QPEL_FILTER_ ## H(src, 1) >> (BIT_DEPTH - 8);             \
@@ -850,6 +852,7 @@ static void FUNC(put_hevc_qpel_v ## V)(int16_t *dst,  ptrdiff_t dststride,     \
     pixel *src = (pixel*)_src;                                                 \
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);                          \
                                                                                \
+    dststride /= sizeof(*dst);                                                 \
     for (y = 0; y < height; y++)  {                                            \
         for (x = 0; x < width; x++)                                            \
             dst[x] = QPEL_FILTER_ ## V(src, srcstride) >> (BIT_DEPTH - 8);     \
@@ -873,6 +876,7 @@ static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst,                 \
     int16_t tmp_array[(MAX_PB_SIZE + 7) * MAX_PB_SIZE];                        \
     int16_t *tmp = tmp_array;                                                  \
                                                                                \
+    dststride /= sizeof(*dst);                                                 \
     src -= ff_hevc_qpel_extra_before[V] * srcstride;                           \
                                                                                \
     for (y = 0; y < height + ff_hevc_qpel_extra[V]; y++) {                     \
@@ -972,6 +976,7 @@ static inline void FUNC(put_hevc_epel_pixels)(int16_t *dst, ptrdiff_t dststride,
     pixel *src          = (pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
 
+    dststride /= sizeof(*dst);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = src[x] << (14 - BIT_DEPTH);
@@ -999,6 +1004,7 @@ static inline void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
     int8_t filter_1 = filter[1];
     int8_t filter_2 = filter[2];
     int8_t filter_3 = filter[3];
+    dststride /= sizeof(*dst);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
@@ -1021,6 +1027,7 @@ static inline void FUNC(put_hevc_epel_v)(int16_t *dst, ptrdiff_t dststride,
     int8_t filter_2 = filter[2];
     int8_t filter_3 = filter[3];
 
+    dststride /= sizeof(*dst);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8);
@@ -1046,6 +1053,7 @@ static inline void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
     int16_t tmp_array[(MAX_PB_SIZE + 3) * MAX_PB_SIZE];
     int16_t *tmp = tmp_array;
 
+    dststride /= sizeof(*dst);
     src -= EPEL_EXTRA_BEFORE * srcstride;
 
     for (y = 0; y < height + EPEL_EXTRA; y++) {
@@ -1122,6 +1130,7 @@ FUNC(put_unweighted_pred)(uint8_t *_dst, ptrdiff_t _dststride,
 #else
     int offset = 0;
 #endif
+    srcstride /= sizeof(*src);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = av_clip_pixel((src[x] + offset) >> shift);
@@ -1147,6 +1156,7 @@ FUNC(put_unweighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
     int offset = 0;
 #endif
 
+    srcstride /= sizeof(*src1);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = av_clip_pixel((src1[x] + src2[x] + offset) >> shift);
@@ -1172,6 +1182,7 @@ FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
     wx     = wlxFlag;
     ox     = olxFlag * (1 << (BIT_DEPTH - 8));
 
+    srcstride /= sizeof(*src);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++) {
             if (log2Wd >= 1) {
@@ -1205,6 +1216,7 @@ FUNC(weighted_pred_avg)(uint8_t denom,
     o0     = ol0Flag * (1 << (BIT_DEPTH - 8));
     o1     = ol1Flag * (1 << (BIT_DEPTH - 8));
 
+    srcstride /= sizeof(*src1);
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++)
             dst[x] = av_clip_pixel((src1[x] * w0 + src2[x] * w1 +
-- 
2.0.0



More information about the libav-devel mailing list