[FFmpeg-devel] [PATCH] Port VDPAU to AVHWAccel infrastructure

Michael Niedermayer michaelni
Sun Jan 3 01:45:55 CET 2010


On Tue, Dec 29, 2009 at 10:25:37AM +0100, Gwenole Beauchesne wrote:
> Hi,
>
> This patch moves VDPAU code to AVHWAccel. An older version (without MPEG-4 
> ASP) was already tested by NVIDIA. However,
> - A separate patch would remove vdpau_internal.h
> - I don't know what to do with older pixfmts since they are now completely 
> obsolete and useless (the hwaccel v2 proposal nukes all pixfmts anyway)
> - It's a plain and straightforward port, no effort was made to fix current 
> bugs in the VDPAU code (including the memory leaks)

[...]
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -613,10 +613,6 @@ typedef struct RcOverride{
>   */
>  #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
>  /**
> - * Codec can export data for HW decoding (VDPAU).
> - */
> -#define CODEC_CAP_HWACCEL_VDPAU    0x0080
> -/**
>   * Codec can output multiple frames per AVPacket
>   */

breaks API, this must be delayed until the next major bump with #if ...

[...]

> +static void vdpau_h264_fill_picture(VdpReferenceFrameH264 *rf, Picture *pic, int pic_structure)
> +{
> +    struct vdpau_render_state *render;
> +
> +    assert(rf);
> +    assert(pic);
> +
> +    if (pic_structure == 0)
> +        pic_structure = pic->reference;
> +
> +    render = (struct vdpau_render_state *)pic->data[3];
> +    assert(render);

lots of new asserts(), these dont belong in this patch


[...]
> @@ -84,70 +125,92 @@ void ff_vdpau_h264_set_reference_frames(MpegEncContext *s)
>              if (rf >= &render->info.h264.referenceFrames[H264_RF_COUNT])
>                  continue;
>  
> -            rf->surface             = render_ref->surface;
> -            rf->is_long_term        = pic->long_ref;
> -            rf->top_is_reference    = (pic->reference & PICT_TOP_FIELD)    ? VDP_TRUE : VDP_FALSE;
> -            rf->bottom_is_reference = (pic->reference & PICT_BOTTOM_FIELD) ? VDP_TRUE : VDP_FALSE;
> -            rf->field_order_cnt[0]  = pic->field_poc[0];
> -            rf->field_order_cnt[1]  = pic->field_poc[1];
> -            rf->frame_idx           = pic_frame_idx;
> +            vdpau_h264_fill_picture(rf, pic, pic->reference);

factorizing this out into a function does not belong in this patch


>  
>              ++rf;
>          }
>      }
>  
> -    for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf) {
> -        rf->surface             = VDP_INVALID_HANDLE;
> -        rf->is_long_term        = 0;
> -        rf->top_is_reference    = 0;
> -        rf->bottom_is_reference = 0;
> -        rf->field_order_cnt[0]  = 0;
> -        rf->field_order_cnt[1]  = 0;
> -        rf->frame_idx           = 0;
> -    }
> +    for (; rf < &render->info.h264.referenceFrames[H264_RF_COUNT]; ++rf)
> +        vdpau_h264_init_picture(rf);

same


[...]
> +static int vdpau_common_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
> +{
> +    MpegEncContext * const s = avctx->priv_data;

> +    struct vdpau_render_state *render;
> +
> +    render = (struct vdpau_render_state *)s->current_picture_ptr->data[3];

can be merged


> +    assert(render);

useless, it will crash on the next line anyway if its NULL
that is unless this code is moved around in which case the assert should stay
for the time. It could be removed in a future patch


[...]
> -    render->info.h264.is_reference                           = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE;
> +    /* fill VdpPictureInfoH264 struct */
> +    render->info.h264.is_reference                           = h->nal_ref_idc != 0;

why?


[...]

also i assume this is tested and works?
and it needs approval from carl as well as he is VDPAU maintainer

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- 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/20100103/906030cb/attachment.pgp>



More information about the ffmpeg-devel mailing list