[FFmpeg-devel] [RFC]Nvidia VDPAU patches

Michael Niedermayer michaelni
Sun Nov 16 21:55:39 CET 2008


On Sun, Nov 16, 2008 at 01:14:43AM +0100, Carl Eugen Hoyos wrote:
> Hi!
>
> In case Michael wants to review them, here are Nvidias patches for ffmpeg 
> for hardware accelerated decoding.
>
> There seem to be one or two unrelated "fixes" (?) for vc1 in this patch, 
> perhaps Kostya can comment.
>
> Carl Eugen

> Index: libavutil/avutil.h
> ===================================================================
> --- libavutil/avutil.h	(revision 14529)
> +++ libavutil/avutil.h	(working copy)
> @@ -117,6 +117,15 @@
>      PIX_FMT_YUV440P,   ///< Planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
>      PIX_FMT_YUVJ440P,  ///< Planar YUV 4:4:0 full scale (jpeg)
>      PIX_FMT_YUVA420P,  ///< Planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
> +    PIX_FMT_VDPAU_MPEG1,        ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_MPEG2_SIMPLE, ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_MPEG2_MAIN,   ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_H264_BASELINE,///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_H264_MAIN,    ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_H264_HIGH,    ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_VC1_SIMPLE,   ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_VC1_MAIN,     ///< VDPAU acceleration via common packet passing(vdpau_remder.h)
> +    PIX_FMT_VDPAU_VC1_ADVANCED, ///< VDPAU acceleration via common packet passing(vdpau_remder.h)

These comments are a little low on usefull info per byte
also why are things split by profile?


[...]
> Index: libavcodec/vdpauvideo.c
> ===================================================================
> --- libavcodec/vdpauvideo.c	(revision 0)
> +++ libavcodec/vdpauvideo.c	(revision 0)
> @@ -0,0 +1,346 @@
> +#include <limits.h>
> +

> +//avcodec include

useless

> +#include "avcodec.h"
> +#include "dsputil.h"
> +#include "mpegvideo.h"
> +#include "h264.h"
> +#include "vc1.h"
> +
> +#undef NDEBUG
> +#include <assert.h>
> +
> +#include "vdpau_render.h"
> +

> +#define ARSIZE(_x_) (sizeof(_x_) / sizeof((_x_)[0]))

FF_ARRAY_ELEMS


> +
> +uint32_t num_reference_surfaces;

non constant global


> +
> +int VDPAU_mpeg_field_start(MpegEncContext *s)

ff prefix


> +{
> +    vdpau_render_state_t * render,* last, * next;
> +    int i;
> +
> +    render = (vdpau_render_state_t*)s->current_picture.data[2];

> +    assert(render != NULL);
> +    if (render == NULL) {
> +        return -1; //make sure that this is render packet
> +    }

this seems a little redudant & contradictionary


[...]
> +        assert(next!=NULL);
> +        if (next == NULL) {
> +            return -1;
> +        }

same


[...]
> +#undef printf

?


[...]
> +    case  FF_B_TYPE:
> +        if (v->bi_type) {
> +            render->info.vc1.picture_type = 4;
> +        }
> +        else {
> +            render->info.vc1.picture_type = 3;
> +        }
> +        break;
> +    case  FF_P_TYPE:
> +        render->info.vc1.picture_type = 1;
> +        break;

> +    case  FF_BI_TYPE:
> +        render->info.vc1.picture_type = 4;
> +        break;

the case can be moved into the if()

[...]
> @@ -954,6 +955,10 @@
>          XVMC_field_end(s);
>      }else
>  #endif
> +#ifdef HAVE_VDPAU

> +    if(s->avctx->vdpau_acceleration){
> +    }else

?

[...]
> @@ -1315,6 +1327,23 @@
>              }
>          }//mpeg2
>  
> +        if(avctx->vdpau_acceleration){
> +            if(s->chroma_format >= 2){
> +                return -2;
> +            }
> +            if(avctx->sub_id == 1){
> +                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg1_420);
> +            }else{
> +                if(avctx->profile == 5){
> +                    avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg2simple_420);

> +                }else
> +                if(avctx->profile == 4){
> +                    avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg2main_420);
> +                }else{

strange indented else if

[...]
> @@ -2081,6 +2117,23 @@
>      avctx->has_b_frames= 0; //true?
>      s->low_delay= 1;
>  
> +    if(avctx->vdpau_acceleration){
> +        if(s->chroma_format >= 2){
> +            return -2;
> +        }
> +        if(avctx->sub_id == 1){
> +            avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg1_420);
> +        }else{
> +            if(avctx->profile == 5){
> +                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg2simple_420);
> +            }else
> +            if(avctx->profile == 4){
> +                avctx->pix_fmt = avctx->get_format(avctx,pixfmt_vdpau_mpg2main_420);
> +            }else{
> +                return -2;
> +            }
> +        }
> +    }else

duplicate



[...]
> Index: libavcodec/vdpau_render.h
> ===================================================================
> --- libavcodec/vdpau_render.h	(revision 0)
> +++ libavcodec/vdpau_render.h	(revision 0)
> @@ -0,0 +1,30 @@
> +#ifndef FFMPEG_VDPAU_RENDER_H
> +#define FFMPEG_VDPAU_RENDER_H
> +
> +#include "vdpau/vdpau.h"
> +#include "vdpau/vdpau_x11.h"
> +

> +//the surface is used for render.
> +#define MP_VDPAU_STATE_USED_FOR_RENDER 1
> +//the surface is needed for reference/prediction, codec manipulates this.
> +#define MP_VDPAU_STATE_USED_FOR_REFERENCE 2

comments are not doxygen compatible


> +
> +#define MP_VDPAU_RENDER_MAGIC 0x1DC8E14B

unused

[...]
> Index: libavcodec/avcodec.h
> ===================================================================
> --- libavcodec/avcodec.h	(revision 14529)
> +++ libavcodec/avcodec.h	(working copy)
> @@ -188,6 +188,10 @@
>      CODEC_ID_BFI,
>      CODEC_ID_CMV,
>      CODEC_ID_MOTIONPIXELS,
> +    CODEC_ID_MPEGVIDEO_VDPAU,
> +    CODEC_ID_H264_VDPAU,
> +    CODEC_ID_VC1_VDPAU,
> +    CODEC_ID_WMV3_VDPAU,
>  
>      /* various PCM "codecs" */
>      CODEC_ID_PCM_S16LE= 0x10000,

it might be worth spliting these off from the normal video codecs


> @@ -500,6 +504,8 @@
>   * This can be used to prevent truncation of the last audio samples.
>   */
>  #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
> +/* Codec can export data for HW decoding (VDPAU). */
> +#define CODEC_CAP_HWACCEL_VDPAU    0x0080
>  
>  //The following defines may change, don't expect compatibility if you use them.
>  #define MB_TYPE_INTRA4x4   0x0001

> @@ -1711,6 +1717,13 @@
>      int xvmc_acceleration;
>  
>      /**
> +     * VDPAU Acceleration
> +     * - encoding: forbidden
> +     * - decoding: set by decoder
> +     */
> +    int vdpau_acceleration;
> +
> +    /**
>       * macroblock decision mode
>       * - encoding: Set by user.
>       * - decoding: unused

adding fields in the middle breaks ABI

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081116/82f8e6c7/attachment.pgp>



More information about the ffmpeg-devel mailing list