PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/media/libvpx/bug671818.patch

http://github.com/zpao/v8monkey
Patch | 162 lines | 148 code | 14 blank | 0 comment | 0 complexity | f4c5b36dccd06ea90ddddf511ce37e24 MD5 | raw file
  1diff --git a/media/libvpx/vp8/vp8_dx_iface.c b/media/libvpx/vp8/vp8_dx_iface.c
  2--- a/media/libvpx/vp8/vp8_dx_iface.c
  3+++ b/media/libvpx/vp8/vp8_dx_iface.c
  4@@ -315,16 +315,46 @@ update_error_state(vpx_codec_alg_priv_t 
  5     if ((res = error->error_code))
  6         ctx->base.err_detail = error->has_detail
  7                                ? error->detail
  8                                : NULL;
  9 
 10     return res;
 11 }
 12 
 13+static void yuvconfig2image(vpx_image_t               *img,
 14+                            const YV12_BUFFER_CONFIG  *yv12,
 15+                            void                      *user_priv)
 16+{
 17+    /** vpx_img_wrap() doesn't allow specifying independent strides for
 18+      * the Y, U, and V planes, nor other alignment adjustments that
 19+      * might be representable by a YV12_BUFFER_CONFIG, so we just
 20+      * initialize all the fields.*/
 21+    img->fmt = yv12->clrtype == REG_YUV ?
 22+        VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
 23+    img->w = yv12->y_stride;
 24+    img->h = (yv12->y_height + 2 * VP8BORDERINPIXELS + 15) & ~15;
 25+    img->d_w = yv12->y_width;
 26+    img->d_h = yv12->y_height;
 27+    img->x_chroma_shift = 1;
 28+    img->y_chroma_shift = 1;
 29+    img->planes[VPX_PLANE_Y] = yv12->y_buffer;
 30+    img->planes[VPX_PLANE_U] = yv12->u_buffer;
 31+    img->planes[VPX_PLANE_V] = yv12->v_buffer;
 32+    img->planes[VPX_PLANE_ALPHA] = NULL;
 33+    img->stride[VPX_PLANE_Y] = yv12->y_stride;
 34+    img->stride[VPX_PLANE_U] = yv12->uv_stride;
 35+    img->stride[VPX_PLANE_V] = yv12->uv_stride;
 36+    img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
 37+    img->bps = 12;
 38+    img->user_priv = user_priv;
 39+    img->img_data = yv12->buffer_alloc;
 40+    img->img_data_owner = 0;
 41+    img->self_allocd = 0;
 42+}
 43 
 44 static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t  *ctx,
 45                                   const uint8_t         *data,
 46                                   unsigned int            data_sz,
 47                                   void                    *user_priv,
 48                                   long                    deadline)
 49 {
 50     vpx_codec_err_t res = VPX_CODEC_OK;
 51@@ -424,30 +454,18 @@ static vpx_codec_err_t vp8_decode(vpx_co
 52         if (vp8dx_receive_compressed_data(ctx->pbi, data_sz, data, deadline))
 53         {
 54             VP8D_COMP *pbi = (VP8D_COMP *)ctx->pbi;
 55             res = update_error_state(ctx, &pbi->common.error);
 56         }
 57 
 58         if (!res && 0 == vp8dx_get_raw_frame(ctx->pbi, &sd, &time_stamp, &time_end_stamp, ppdeblocking, ppnoise, ppflag))
 59         {
 60-            /* Align width/height */
 61-            unsigned int a_w = (sd.y_width + 15) & ~15;
 62-            unsigned int a_h = (sd.y_height + 15) & ~15;
 63-
 64-            vpx_img_wrap(&ctx->img, VPX_IMG_FMT_I420,
 65-                         a_w + 2 * VP8BORDERINPIXELS,
 66-                         a_h + 2 * VP8BORDERINPIXELS,
 67-                         1,
 68-                         sd.buffer_alloc);
 69-            vpx_img_set_rect(&ctx->img,
 70-                             VP8BORDERINPIXELS, VP8BORDERINPIXELS,
 71-                             sd.y_width, sd.y_height);
 72+            yuvconfig2image(&ctx->img, &sd, user_priv);
 73             ctx->img_avail = 1;
 74-
 75         }
 76     }
 77 
 78     return res;
 79 }
 80 
 81 static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t  *ctx,
 82                                   vpx_codec_iter_t      *iter)
 83diff --git a/media/libvpx/vpx_scale/generic/yv12config.c b/media/libvpx/vpx_scale/generic/yv12config.c
 84--- a/media/libvpx/vpx_scale/generic/yv12config.c
 85+++ b/media/libvpx/vpx_scale/generic/yv12config.c
 86@@ -42,50 +42,61 @@ vp8_yv12_de_alloc_frame_buffer(YV12_BUFF
 87 /****************************************************************************
 88  *
 89  ****************************************************************************/
 90 int
 91 vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border)
 92 {
 93 /*NOTE:*/
 94 
 95-    int yplane_size = (height + 2 * border) * (width + 2 * border);
 96-    int uvplane_size = ((1 + height) / 2 + border) * ((1 + width) / 2 + border);
 97-
 98     if (ybf)
 99     {
100+        int y_stride = ((width + 2 * border) + 31) & ~31;
101+        int yplane_size = (height + 2 * border) * y_stride;
102+        /** There is currently a bunch of code which assumes
103+          *  uv_stride == y_stride/2, so enforce this here. */
104+        int uv_width = width >> 1;
105+        int uv_height = height >> 1;
106+        int uv_stride = y_stride >> 1;
107+        int uvplane_size = ((1 + height) / 2 + border) * uv_stride;
108+
109         vp8_yv12_de_alloc_frame_buffer(ybf);
110 
111+        /** Only support allocating buffers that have a height and width that
112+          *  are multiples of 16, and a border that's a multiple of 32.
113+          * The border restriction is required to get 16-byte alignment of the
114+          *  start of the chroma rows without intoducing an arbitrary gap
115+          *  between planes, which would break the semantics of things like
116+          *  vpx_img_set_rect(). */
117+        if ((width & 0xf) | (height & 0xf) | (border & 0x1f))
118+            return -3;
119+
120         ybf->y_width  = width;
121         ybf->y_height = height;
122-        ybf->y_stride = width + 2 * border;
123+        ybf->y_stride = y_stride;
124 
125-        ybf->uv_width = (1 + width) / 2;
126-        ybf->uv_height = (1 + height) / 2;
127-        ybf->uv_stride = ybf->uv_width + border;
128+        ybf->uv_width = uv_width;
129+        ybf->uv_height = uv_height;
130+        ybf->uv_stride = uv_stride;
131 
132         ybf->border = border;
133         ybf->frame_size = yplane_size + 2 * uvplane_size;
134 
135         /* Added 2 extra lines to framebuffer so that copy12x12 doesn't fail
136          * when we have a large motion vector in V on the last v block.
137          * Note : We never use these pixels anyway so this doesn't hurt.
138          */
139-        ybf->buffer_alloc = (unsigned char *) duck_memalign(32,  ybf->frame_size + (ybf->y_stride * 2) + 32, 0);
140+        ybf->buffer_alloc = (unsigned char *) vpx_memalign(32,  ybf->frame_size);
141 
142         if (ybf->buffer_alloc == NULL)
143             return -1;
144 
145-        ybf->y_buffer = ybf->buffer_alloc + (border * ybf->y_stride) + border;
146-
147-        if (yplane_size & 0xf)
148-            yplane_size += 16 - (yplane_size & 0xf);
149-
150-        ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2  * ybf->uv_stride) + border / 2;
151-        ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2  * ybf->uv_stride) + border / 2;
152+        ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
153+        ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2  * uv_stride) + border / 2;
154+        ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2  * uv_stride) + border / 2;
155     }
156     else
157     {
158         return -2;
159     }
160 
161     return 0;
162 }