summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhandbrake <[email protected]>2013-04-03 06:25:12 +0000
committerhandbrake <[email protected]>2013-04-03 06:25:12 +0000
commit75c4aac650529cab832f723cefed6dc83f991447 (patch)
tree40e4277b0635b99762f6ebea0e2b8f964c3b0630
parentb34ec3996e3aa86c26f2ab245215509573d69de1 (diff)
fixed vob video issue
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/opencl@5378 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/decavcodec.c88
-rw-r--r--libhb/oclnv12toyuv.c32
-rw-r--r--libhb/vadxva2.c2
3 files changed, 73 insertions, 49 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 3df00006a..9c1bc1ef9 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -622,57 +622,55 @@ static hb_buffer_t *copy_frame( hb_work_private_t *pv, AVFrame *frame )
return buf;
}
else
- {
#endif
- hb_buffer_t *buf = hb_video_buffer_init( w, h );
- uint8_t *dst = buf->data;
-
- if (context->pix_fmt != AV_PIX_FMT_YUV420P || w != context->width ||
- h != context->height)
{
- // have to convert to our internal color space and/or rescale
- AVPicture dstpic;
- hb_avpicture_fill(&dstpic, buf);
+ hb_buffer_t *buf = hb_video_buffer_init( w, h );
+ uint8_t *dst = buf->data;
- if (pv->sws_context == NULL ||
- pv->sws_width != context->width ||
- pv->sws_height != context->height ||
- pv->sws_pix_fmt != context->pix_fmt)
+ if (context->pix_fmt != AV_PIX_FMT_YUV420P || w != context->width ||
+ h != context->height)
{
- if (pv->sws_context != NULL)
- sws_freeContext(pv->sws_context);
- pv->sws_context = hb_sws_get_context(context->width,
- context->height,
- context->pix_fmt,
- w, h, AV_PIX_FMT_YUV420P,
- SWS_LANCZOS|SWS_ACCURATE_RND);
- pv->sws_width = context->width;
- pv->sws_height = context->height;
- pv->sws_pix_fmt = context->pix_fmt;
+ // have to convert to our internal color space and/or rescale
+ AVPicture dstpic;
+ hb_avpicture_fill(&dstpic, buf);
+
+ if (pv->sws_context == NULL ||
+ pv->sws_width != context->width ||
+ pv->sws_height != context->height ||
+ pv->sws_pix_fmt != context->pix_fmt)
+ {
+ if (pv->sws_context != NULL)
+ sws_freeContext(pv->sws_context);
+ pv->sws_context = hb_sws_get_context(context->width,
+ context->height,
+ context->pix_fmt,
+ w, h, AV_PIX_FMT_YUV420P,
+ SWS_LANCZOS|SWS_ACCURATE_RND);
+ pv->sws_width = context->width;
+ pv->sws_height = context->height;
+ pv->sws_pix_fmt = context->pix_fmt;
+ }
+ sws_scale(pv->sws_context,
+ (const uint8_t* const *)frame->data, frame->linesize,
+ 0, context->height, dstpic.data, dstpic.linesize);
}
- sws_scale(pv->sws_context,
- (const uint8_t* const *)frame->data, frame->linesize,
- 0, context->height, dstpic.data, dstpic.linesize);
- }
- else
- {
- w = buf->plane[0].stride;
- h = buf->plane[0].height;
- dst = buf->plane[0].data;
- copy_plane( dst, frame->data[0], w, frame->linesize[0], h );
- w = buf->plane[1].stride;
- h = buf->plane[1].height;
- dst = buf->plane[1].data;
- copy_plane( dst, frame->data[1], w, frame->linesize[1], h );
- w = buf->plane[2].stride;
- h = buf->plane[2].height;
- dst = buf->plane[2].data;
- copy_plane( dst, frame->data[2], w, frame->linesize[2], h );
+ else
+ {
+ w = buf->plane[0].stride;
+ h = buf->plane[0].height;
+ dst = buf->plane[0].data;
+ copy_plane( dst, frame->data[0], w, frame->linesize[0], h );
+ w = buf->plane[1].stride;
+ h = buf->plane[1].height;
+ dst = buf->plane[1].data;
+ copy_plane( dst, frame->data[1], w, frame->linesize[1], h );
+ w = buf->plane[2].stride;
+ h = buf->plane[2].height;
+ dst = buf->plane[2].data;
+ copy_plane( dst, frame->data[2], w, frame->linesize[2], h );
+ }
+ return buf;
}
- return buf;
-#ifdef USE_HWD
-}
-#endif
}
#ifdef USE_HWD
diff --git a/libhb/oclnv12toyuv.c b/libhb/oclnv12toyuv.c
index 26b725bfa..a540e49c1 100644
--- a/libhb/oclnv12toyuv.c
+++ b/libhb/oclnv12toyuv.c
@@ -100,6 +100,24 @@ static int hb_init_nv12toyuv_ocl( KernelEnv *kenv, int w, int h, hb_va_dxva2_t *
return 0;
}
+static uint8_t *copy_plane( uint8_t *dst, uint8_t* src, int dstride, int sstride,
+ int h )
+{
+ if ( dstride == sstride )
+ {
+ memcpy( dst, src, dstride * h );
+ return dst + dstride * h;
+ }
+ int lbytes = dstride <= sstride? dstride : sstride;
+ while ( --h >= 0 )
+ {
+ memcpy( dst, src, lbytes );
+ src += sstride;
+ dst += dstride;
+ }
+ return dst;
+}
+
/**
* Run nv12 to yuv kernel.
*/
@@ -158,9 +176,17 @@ static int hb_nv12toyuv( void **userdata, KernelEnv *kenv )
AVPicture pic_crop;
clEnqueueReadBuffer( kenv->command_queue, dxva2->cl_mem_yuv, CL_TRUE, 0, in_bytes, dxva2->nv12toyuv_tmp_out, 0, NULL, NULL );
hb_buffer_t *in = hb_video_buffer_init( w, h );
- memcpy( in->plane[0].data, dxva2->nv12toyuv_tmp_out, w * h );
- memcpy( in->plane[1].data, dxva2->nv12toyuv_tmp_out + w * h, ( w * h )>>2 );
- memcpy( in->plane[2].data, dxva2->nv12toyuv_tmp_out + w * h + ( ( w * h )>>2 ), ( w * h )>>2 );
+
+ int wmp = in->plane[0].stride;
+ int hmp = in->plane[0].height;
+ copy_plane( in->plane[0].data, dxva2->nv12toyuv_tmp_out, wmp, w, hmp );
+ wmp = in->plane[1].stride;
+ hmp = in->plane[1].height;
+ copy_plane( in->plane[1].data, dxva2->nv12toyuv_tmp_out + w * h, wmp, w>>1, hmp );
+ wmp = in->plane[2].stride;
+ hmp = in->plane[2].height;
+ copy_plane( in->plane[2].data, dxva2->nv12toyuv_tmp_out + w * h +( ( w * h )>>2 ), wmp, w>>1, hmp );
+
hb_avpicture_fill( &pic_in, in );
av_picture_crop( &pic_crop, &pic_in, in->f.fmt, crop[0], crop[2] );
int i, ww = w - ( crop[2] + crop[3] ), hh = h - ( crop[0] + crop[1] );
diff --git a/libhb/vadxva2.c b/libhb/vadxva2.c
index 369f51b48..9cd780b3c 100644
--- a/libhb/vadxva2.c
+++ b/libhb/vadxva2.c
@@ -592,7 +592,7 @@ void hb_init_filter( cl_mem src, int srcwidth, int srcheight, uint8_t* dst, int
cl_mem cl_outbuf;
- if( !hb_create_buffer( &(cl_outbuf), CL_MEM_WRITE_ONLY, STEP ) )
+ if( !hb_create_buffer( &(cl_outbuf), CL_MEM_WRITE_ONLY, OUTSTEP ) )
{
hb_log("av_create_buffer cl_outbuf Error");
return;