]> granicus.if.org Git - handbrake/commitdiff
qsv: Allocate planes contiguously.
authormaxd <maxim.d33@gmail.com>
Tue, 31 Jan 2017 09:35:37 +0000 (10:35 +0100)
committerBradley Sepos <bradley@bradleysepos.com>
Thu, 2 Feb 2017 19:38:54 +0000 (14:38 -0500)
Better performance and less prone to crashing.

Fixes #540 and closes #558.

(cherry picked from commit 6aa1b40aead1653b39c93195aed4e920b6b0fcc9)

libhb/enc_qsv.c

index a29833123c4cd029efde9cff1be7f3c83f8d6822..2009edc63a3ad160b971df260dcc42b8a22c2eab 100644 (file)
@@ -309,8 +309,8 @@ static int qsv_hevc_make_header(hb_work_object_t *w, mfxSession session)
     mfxU16 Height            = pv->param.videoParam->mfx.FrameInfo.Height;
     mfxU16 Width             = pv->param.videoParam->mfx.FrameInfo.Width;
     frameSurface1.Info       = pv->param.videoParam->mfx.FrameInfo;
-    frameSurface1.Data.VU    = av_mallocz(Width * Height / 2);
-    frameSurface1.Data.Y     = av_mallocz(Width * Height);
+    frameSurface1.Data.Y     = av_mallocz(Width * Height * 3 / 2);
+    frameSurface1.Data.VU    = frameSurface1.Data.Y + Width * Height;
     frameSurface1.Data.Pitch = Width;
 
     /* Encode a single blank frame */
@@ -437,7 +437,6 @@ static int qsv_hevc_make_header(hb_work_object_t *w, mfxSession session)
 
 end:
     hb_buffer_close(&bitstream_buf);
-    av_free(frameSurface1.Data.VU);
     av_free(frameSurface1.Data.Y);
     return ret;
 }
@@ -596,8 +595,8 @@ int qsv_enc_init(hb_work_private_t *pv)
             mfxFrameInfo info         = pv->param.videoParam->mfx.FrameInfo;
             surface->Info             = info;
             surface->Data.Pitch       = info.Width;
-            surface->Data.Y           = av_mallocz(info.Width * info.Height);
-            surface->Data.VU          = av_mallocz(info.Width * info.Height / 2);
+            surface->Data.Y           = av_mallocz(info.Width * info.Height * 3 / 2);
+            surface->Data.VU          = surface->Data.Y + info.Width * info.Height;
             qsv_encode->p_surfaces[i] = surface;
         }
     }
@@ -1458,7 +1457,6 @@ void encqsvClose(hb_work_object_t *w)
                     {
                         if (pv->is_sys_mem)
                         {
-                            av_freep(&qsv_enc_space->p_surfaces[i]->Data.VU);
                             av_freep(&qsv_enc_space->p_surfaces[i]->Data.Y);
                         }
                         av_freep(&qsv_enc_space->p_surfaces[i]);