[vlc-devel] [PATCH] androidsurface: setup format depending on surface format
Rémi Denis-Courmont
remi at remlab.net
Mon Dec 31 17:49:35 CET 2012
On Mon, 31 Dec 2012 09:42:58 -0500, Edward Wang
<edward.c.wang at compdigitec.com> wrote:
> @@ -174,10 +182,38 @@ static int Open(vlc_object_t *p_this) {
>
> /* Setup chroma */
> video_format_t fmt = vd->fmt;
> - fmt.i_chroma = VLC_CODEC_RGB32;
> - fmt.i_rmask = 0x000000ff;
> - fmt.i_gmask = 0x0000ff00;
> - fmt.i_bmask = 0x00ff0000;
> + int surface_format = AndroidRetrieveSurfaceFormat( sys );
> + switch( surface_format ) {
> + case ANDROID_IMAGE_FORMAT_YV12:
> + msg_Dbg( vd, "ImageFormat.YV12" );
> + fmt.i_chroma = VLC_CODEC_I420;
FWIW, VLC has VLC_CODEC_YV12.
> + break;
> +
> + case ANDROID_PIXEL_FORMAT_RGB_565:
> + msg_Dbg( vd, "PixelFormat.RGB_565" );
> + fmt.i_chroma = VLC_CODEC_RGB16;
> + fmt.i_bmask = 0x0000001f;
> + fmt.i_gmask = 0x000007e0;
> + fmt.i_rmask = 0x0000f800;
> + break;
> +
> + case ANDROID_PIXEL_FORMAT_RGBX_8888:
> + msg_Dbg( vd, "PixelFormat.RGBX_8888" );
> + fmt.i_chroma = VLC_CODEC_RGB32;
> + fmt.i_rmask = 0x000000ff;
> + fmt.i_gmask = 0x0000ff00;
> + fmt.i_bmask = 0x00ff0000;
> + break;
> +
> + default:
> + // FIXME: supposed to be rgbx8888 for now
> + msg_Dbg( vd, "ImageFormat.(%d)", surface_format );
> + fmt.i_chroma = VLC_CODEC_RGB32;
> + fmt.i_rmask = 0x000000ff;
> + fmt.i_gmask = 0x0000ff00;
> + fmt.i_bmask = 0x00ff0000;
> + break;
Normally, you return EGENERIC if the format is unsupported.
> + }
> video_format_FixRgb(&fmt);
>
> /* Create the associated picture */
> @@ -283,9 +388,22 @@ static int AndroidLockSurface(picture_t *picture)
{
> return VLC_EGENERIC;
> }
>
> - picture->p->p_pixels = (uint8_t*)info->bits;
> - picture->p->i_pitch = 4 * info->s;
> - picture->p->i_lines = info->h;
> + switch( info->format )
> + {
> + case ANDROID_IMAGE_FORMAT_YV12:
> + SetupPictureYV12( info, picture );
> + break;
> + case ANDROID_PIXEL_FORMAT_RGB_565:
> + SetupPictureRGB565( info, picture );
> + break;
> + case ANDROID_PIXEL_FORMAT_RGBX_8888:
> + SetupPictureRGBX8888( info, picture );
> + break;
> + default:
> + // FIXME: supposed to be rgbx8888 for now
> + SetupPictureRGBX8888( info, picture );
> + break;
> + }
Could use a precomputed function pointer...
>
> return VLC_SUCCESS;
> }
--
Rémi Denis-Courmont
Sent from my collocated server
More information about the vlc-devel
mailing list