[MPlayer-dev-eng] VA API support for MPlayer

Diego Biurrun diego at biurrun.de
Wed Dec 24 19:55:10 CET 2008


On Wed, Dec 24, 2008 at 07:40:00PM +0100, Gwenolé Beauchesne wrote:
>
> This was done simply to evaluate performance and capabilities of the  
> various chipsets, we actually are not using mplayer in our products. So, 
> excuse me for the initial low quality of the patches.

Well, let's see what you have..

> --- libmpcodecs/vd_ffmpeg.c	(revision 28164)
> +++ libmpcodecs/vd_ffmpeg.c	(working copy)
> @@ -148,6 +161,52 @@
>          case IMGFMT_XVMC_MOCO_MPEG2:
>              if(avctx->pix_fmt==PIX_FMT_XVMC_MPEG2_IDCT) return CONTROL_TRUE;
>  #endif
> +#ifdef CONFIG_VAAPI
> +	    case IMGFMT_VAAPI_MPEG2_SIMPLE:
> +	      if (avctx->pix_fmt == PIX_FMT_VAAPI_MPEG2_SIMPLE)
> +		return CONTROL_TRUE;
> +	      break;

The rest of the code uses 4 space indentation, respect that.

> --- libvo/vo_vaapi.c	(revision 0)
> +++ libvo/vo_vaapi.c	(revision 0)
> @@ -0,0 +1,637 @@
> +/*
> + *  vo_vaapi.c - VA API Renderer for MPlayer
> + *
> + *  Copyright (C) 2008 Splitted-Desktop Systems
> + *
> + *  Maintainer: Gwenole Beauchesne <gbeauchesne at splitted-desktop.com>
> + *
> + *  This file is part of MPlayer.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License along
> + *  with this program; if not, write to the Free Software Foundation, Inc.,
> + *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> + */

Please use our standard license header instead.

> +static int VAProfile_from_imgfmt(uint32_t format)
> +{
> +  switch (format) {
> +  case IMGFMT_VAAPI_MPEG2_SIMPLE:	return VAProfileMPEG2Simple;
> +  case IMGFMT_VAAPI_MPEG2_MAIN:		return VAProfileMPEG2Main;
> +  case IMGFMT_VAAPI_MPEG4_SIMPLE:	return VAProfileMPEG4Simple;
> +  case IMGFMT_VAAPI_MPEG4_ADVANCED:	return VAProfileMPEG4AdvancedSimple;
> +  case IMGFMT_VAAPI_MPEG4_MAIN:		return VAProfileMPEG4Main;
> +  case IMGFMT_VAAPI_H264_BASELINE:	return VAProfileH264Baseline;
> +  case IMGFMT_VAAPI_H264_MAIN:		return VAProfileH264Main;
> +  case IMGFMT_VAAPI_H264_HIGH:		return VAProfileH264High;
> +  case IMGFMT_VAAPI_VC1_SIMPLE:		return VAProfileVC1Simple;
> +  case IMGFMT_VAAPI_VC1_MAIN:		return VAProfileVC1Main;
> +  case IMGFMT_VAAPI_VC1_ADVANCED:	return VAProfileVC1Advanced;
> +  }
> +  return -1;
> +}

New code for MPlayer should use 4 space indentation, no tabs, no
trailing whitespace like FFmpeg.

> --- configure	(revision 28164)
> +++ configure	(working copy)
> @@ -4125,7 +4129,29 @@
>  
> +if test "$_vaapi" = yes ; then
> +  _def_vaapi='#define CONFIG_VAAPI 1'
> +  _libs_mplayer="$_libs_mplayer -lva"
> +  _vosrc="$_vosrc vo_vaapi.c"

_vosrc no longer exists, you need to hook this module up in the Makefile
instead.

> @@ -8129,12 +8156,14 @@
>  HAVE_PTHREADS = $_pthreads
>  HAVE_W32THREADS = $_w32threads
>  HAVE_YASM = $_have_yasm
> +HAVE_VAAPI = $_vaapi

This is unused, drop it.

> --- libavcodec/h264.c	(revision 16238)
> +++ libavcodec/h264.c	(working copy)
> @@ -72,6 +72,11 @@
>  
> +/* Defined in vaapivideo.c */
> +int VAAPI_h264_frame_start(H264Context *h);
> +int VAAPI_h264_frame_end(H264Context *h);
> +int VAAPI_h264_decode_slice(H264Context *h, const uint8_t *buffer, uint32_t size);

Forward declarations are ugly.

> @@ -101,6 +106,36 @@
>  
> +#undef printf

Ahem...

> --- libavcodec/vaapivideo.c	(revision 0)
> +++ libavcodec/vaapivideo.c	(revision 0)
> @@ -0,0 +1,1240 @@
> +/*
> + *  vaapivideo.c - VA API Decoder for FFmpeg
> + *
> + *  Copyright (C) 2008 Splitted-Desktop Systems
> + *
> + *  Maintainer: Gwenole Beauchesne <gbeauchesne at splitted-desktop.com>
> + *
> + *  This file is part of FFmpeg.
> + *
> + *  This library is free software; you can redistribute it and/or
> + *  modify it under the terms of the GNU Lesser General Public
> + *  License as published by the Free Software Foundation; either
> + *  version 2.1 of the License, or (at your option) any later version.
> + *
> + *  This library is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *  Lesser General Public License for more details.
> + *
> + *  You should have received a copy of the GNU Lesser General Public
> + *  License along with this library; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
> + */

This is not a standard FFmpeg license header.

> +/* Initialize VA API render state */
> +static int VAAPI_render_state_init(vaapi_render_state_t *rds)
> +{
> +  //D(bug("VAAPI_render_state_init(): surface 0x%08x\n", rds->surface));
> +
> +  assert(rds->pic_param_buf_id == 0);
> +  rds->pic_param_buf_id = 0;
> +  assert(rds->iq_matrix_buf_id == 0);
> +  rds->iq_matrix_buf_id = 0;
> +  assert(rds->slice_param_buf_id == 0);
> +  rds->slice_param_buf_id = 0;
> +  assert(rds->slice_data_buf_id == 0);
> +  rds->slice_data_buf_id = 0;
> +  rds->slice_data_size = 0;
> +  rds->slice_count = 0;
> +  assert(!((rds->slice_count_max > 0) ^ (rds->slice_params != NULL)));
> +  assert(!((rds->slice_data_size_max > 0) ^ (rds->slice_data != NULL)));
> +  return 0;
> +}

4 space indentation, no tabs, no trailing whitespace

> --- libavcodec/mpeg12.c	(revision 16238)
> +++ libavcodec/mpeg12.c	(working copy)
> @@ -68,10 +68,21 @@
>  void XVMC_pack_pblocks(MpegEncContext *s,int cbp);
>  void XVMC_init_block(MpegEncContext *s);//set s->block
>  
> +/* Defined in vaapivideo.c */
> +int VAAPI_mpeg2_field_start(MpegEncContext *s);
> +int VAAPI_mpeg2_field_end(MpegEncContext *s);
> +int VAAPI_mpeg2_decode_slice(MpegEncContext *s, int mb_y,
> +                             uint8_t *buffer, uint32_t offset,
> +                             uint32_t size);
> +int VAAPI_init_slice_data(MpegEncContext *s,
> +                          uint8_t *buffer, uint32_t buffer_size);

forward declarations again..

> --- libavcodec/h263dec.c	(revision 16238)
> +++ libavcodec/h263dec.c	(working copy)
> @@ -35,6 +35,13 @@
>  
> +/* Defined in vaapivideo.c */
> +int VAAPI_mpeg4_frame_start(MpegEncContext *s);
> +int VAAPI_mpeg4_frame_end(MpegEncContext *s);
> +int VAAPI_mpeg4_decode_slice_init(MpegEncContext *s, const uint8_t *buffer, uint32_t offset);
> +int VAAPI_mpeg4_decode_slice(MpegEncContext *s);
> +int VAAPI_mpeg4_decode_slice_done(MpegEncContext *s, const uint8_t *buffer_end);

.. and again ..

> --- libavcodec/vaapi_render.h	(revision 0)
> +++ libavcodec/vaapi_render.h	(revision 0)
> @@ -0,0 +1,97 @@
> +/*
> + *  vaapi_render.h - Shared VA API data between FFmpeg and MPlayer
> + *
> + *  Copyright (C) 2008 Splitted-Desktop Systems
> + *
> + *  Maintainer: Gwenole Beauchesne <gbeauchesne at splitted-desktop.com>
> + *
> + *  This file is part of FFmpeg.
> + *
> + *  This library is free software; you can redistribute it and/or
> + *  modify it under the terms of the GNU Lesser General Public
> + *  License as published by the Free Software Foundation; either
> + *  version 2.1 of the License, or (at your option) any later version.
> + *
> + *  This library is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + *  Lesser General Public License for more details.
> + *
> + *  You should have received a copy of the GNU Lesser General Public
> + *  License along with this library; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
> + */

Again, not a standard license header...

> +#ifndef FFMPEG_VAAPI_RENDER_H
> +#define FFMPEG_VAAPI_RENDER_H

AVCODEC_

> +typedef struct {
> +  VADisplay display;
> +  VAConfigID config_id;
> +  VAContextID context_id;
> +} vaapi_context_t;

The _t namespace is reserved by POSIX, use another name, possibly
drop the typedef.

> +typedef struct {
> +} vaapi_render_state_t;

ditto

Diego



More information about the MPlayer-dev-eng mailing list