On Sun, 2014-03-16 at 23:50 -0600, Xiang, Haihao wrote:
> It would be better to add a pre-defined fourcc code for YV16 in va.h

Thanks for your review.

OK. I can send a patch about YV16 fourcc code for libva.
> 
> > Signed-off-by: Zhao Yakui <yakui.z...@intel.com>
> > ---
> >  src/i965_drv_video.c | 26 +++++++++++++++++++++++++-
> >  1 file changed, 25 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
> > index 0453c04..f306d91 100755
> > --- a/src/i965_drv_video.c
> > +++ b/src/i965_drv_video.c
> > @@ -816,7 +816,8 @@ i965_surface_native_memory(VADriverContextP ctx,
> >      // todo, should we disable tiling for 422 format?
> >      if (expected_fourcc == VA_FOURCC('I', '4', '2', '0') ||
> >          expected_fourcc == VA_FOURCC('I', 'Y', 'U', 'V') ||
> > -        expected_fourcc == VA_FOURCC('Y', 'V', '1', '2'))
> > +        expected_fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
> > +        expected_fourcc == VA_FOURCC('Y', 'V', '1', '6'))
> >          tiling = 0;
> >             
> >      i965_check_alloc_surface_bo(ctx, obj_surface, tiling, expected_fourcc, 
> > get_sampling_from_fourcc(expected_fourcc));
> > @@ -963,6 +964,19 @@ i965_suface_external_memory(VADriverContextP ctx,
> >  
> >          break;
> >  
> > +    case VA_FOURCC('Y', 'V', '1', '6'):
> > +        assert(memory_attibute->num_planes == 3);
> > +        assert(memory_attibute->pitches[1] == memory_attibute->pitches[2]);
> > +
> > +        obj_surface->subsampling = SUBSAMPLE_YUV422H;
> > +        obj_surface->y_cr_offset = memory_attibute->offsets[1] / 
> > obj_surface->width;
> > +        obj_surface->y_cb_offset = memory_attibute->offsets[2] / 
> > obj_surface->width;
> > +        obj_surface->cb_cr_width = obj_surface->orig_width / 2;
> > +        obj_surface->cb_cr_height = obj_surface->orig_height;
> > +        obj_surface->cb_cr_pitch = memory_attibute->pitches[1];
> > +
> > +        break;
> > +
> >      case VA_FOURCC('4', '2', '2', 'V'):
> >          assert(memory_attibute->num_planes == 3);
> >          assert(memory_attibute->pitches[1] == memory_attibute->pitches[2]);
> > @@ -3047,6 +3061,15 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
> >              region_height = obj_surface->height + obj_surface->height / 2;
> >              break;
> >  
> > +        case VA_FOURCC('Y', 'V', '1', '6'):
> > +            obj_surface->cb_cr_width = obj_surface->orig_width / 2;
> > +            obj_surface->cb_cr_height = obj_surface->orig_height;
> > +            obj_surface->y_cr_offset = obj_surface->height;
> > +            obj_surface->y_cb_offset = obj_surface->y_cr_offset + 
> > ALIGN(obj_surface->cb_cr_height, 32) / 2;
> 
> y_cb_offset is the veritical offset in rows from the surface base
> Address to the start of the cb plane in the allocated surface memory. so
> it should be obj_surface->y_cb_offset = obj_surface->y_cr_offset +
> ALIGN(obj_surface->cb_cr_height, 32).

The YV16 is equal to "YUV422H" mode. As the width of Cb/Cr plane is
equal to 1/2 the width of Y plane, we can use "width * 1/2 height " to
allocate the required memory for U/V plane.
At the same time based on my understanding, the y_cb_offset/y_cr_offset
should be calculated by using "cb_offset / y_pitch[0]".

In such case IMO it is OK to use the above code.

How do you think?

thanks.
    Yakui


>  
> 
> > +            obj_surface->cb_cr_pitch = obj_surface->width / 2;
> > +            region_height = obj_surface->height + 
> > ALIGN(obj_surface->cb_cr_height, 32);
> 
> Need to fix region_height as well.
> 
> 
> > +            break;
> > +
> >          case VA_FOURCC('Y', 'V', '1', '2'):
> >          case VA_FOURCC('I', '4', '2', '0'):
> >              if (fourcc == VA_FOURCC('Y', 'V', '1', '2')) {
> > @@ -3340,6 +3363,7 @@ get_sampling_from_fourcc(unsigned int fourcc)
> >      case VA_FOURCC('Y', 'U', 'Y', '2'):
> >      case VA_FOURCC('U', 'Y', 'V', 'Y'):
> >      case VA_FOURCC('4', '2', '2', 'H'):
> > +    case VA_FOURCC('Y', 'V', '1', '6'):
> >          surface_sampling = SUBSAMPLE_YUV422H;
> >          break;
> >      case VA_FOURCC('4', '2', '2', 'V'):
> 
> 


_______________________________________________
Libva mailing list
Libva@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to