Skip to content

Commit

Permalink
[vdpau] Probe hw capabilities (experimental)
Browse files Browse the repository at this point in the history
  • Loading branch information
mean committed Feb 9, 2017
1 parent a358a6c commit 868f24f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
33 changes: 18 additions & 15 deletions avidemux/common/ADM_videoCodec/src/ADM_ffmpeg_vdpau.cpp
Expand Up @@ -60,7 +60,8 @@ typedef enum
ADM_VDPAU_INVALID=0,
ADM_VDPAU_H264=1,
ADM_VDPAU_MPEG2=2,
ADM_VDPAU_VC1=3
ADM_VDPAU_VC1=3,
ADM_VDPAU_H265=4,
}ADM_VDPAU_TYPE;

#ifdef USE_VDPAU
Expand Down Expand Up @@ -212,20 +213,26 @@ static enum AVPixelFormat vdpauGetFormat(struct AVCodecContext *avctx, const en
AVCodecID id=AV_CODEC_ID_NONE;
AVPixelFormat c;
AVPixelFormat outPix;
int maxW,maxH;
if(avctx->sw_pix_fmt==AV_PIX_FMT_YUV420P) // doont even try non yv12 for the moment
for(i=0;fmt[i]!=AV_PIX_FMT_NONE;i++)
{
c=fmt[i];
ADM_info("[vdpau]: Evaluating %d\n",c);
if(c!=AV_PIX_FMT_VDPAU) continue;
#define FMT_V_CHECK(x,y) case AV_CODEC_ID_##x: outPix=AV_PIX_FMT_VDPAU_##y;id=avctx->codec_id;break;
#define FMT_V_CHECK(x,y) case AV_CODEC_ID_##x: \
if(admVdpau::queryDecoderCapabilities(y,&maxW,&maxH)) \
{ id=avctx->codec_id;\
outPix=AV_PIX_FMT_VDPAU ;}else {ADM_info(#x ":Not supported by HW\n");}\
break;
switch(avctx->codec_id)
{
FMT_V_CHECK(H264,H264)
FMT_V_CHECK(MPEG1VIDEO,MPEG1)
FMT_V_CHECK(MPEG2VIDEO,MPEG2)
FMT_V_CHECK(WMV3,WMV3)
FMT_V_CHECK(VC1,VC1)
FMT_V_CHECK(H264, VDP_DECODER_PROFILE_H264_HIGH)
FMT_V_CHECK(HEVC, VDP_DECODER_PROFILE_HEVC_MAIN)
FMT_V_CHECK(MPEG1VIDEO,VDP_DECODER_PROFILE_MPEG1)
FMT_V_CHECK(MPEG2VIDEO,VDP_DECODER_LEVEL_MPEG2_HL)
FMT_V_CHECK(WMV3, VDP_DECODER_PROFILE_VC1_MAIN)
FMT_V_CHECK(VC1, VDP_DECODER_PROFILE_VC1_MAIN)
default:
continue;
break;
Expand Down Expand Up @@ -278,27 +285,23 @@ decoderFFVDPAU::decoderFFVDPAU(struct AVCodecContext *avctx,decoderFF *parent) :
{
alive=true;
avVdCtx=NULL;
ADM_VDPAU_TYPE vdpauType=ADM_VDPAU_INVALID;

AVCodecID codecID;
int vdpDecoder=0;
const char *name="";
VdpDevice dev=(VdpDevice)(uint64_t)admVdpau::getVdpDevice();

switch(_context->codec_id)
{
case AV_CODEC_ID_HEVC:
name="h265";
break;
case AV_CODEC_ID_H264:
vdpauType=ADM_VDPAU_H264;
name="h264";
vdpDecoder=VDP_DECODER_PROFILE_H264_HIGH;
break;
case AV_CODEC_ID_VC1:
vdpauType=ADM_VDPAU_VC1;
name="vc1";
vdpDecoder=VDP_DECODER_PROFILE_VC1_ADVANCED;
break;
case AV_CODEC_ID_MPEG2VIDEO:
vdpauType=ADM_VDPAU_MPEG2;
vdpDecoder=VDP_DECODER_PROFILE_MPEG2_MAIN;
name="mpegvideo";
break;
default:
Expand Down
Expand Up @@ -104,6 +104,9 @@ class admVdpau
uint32_t attrCount,
const VdpVideoMixerAttribute *xkeys,
void * const* values);
static bool queryDecoderCapabilities( VdpDecoderProfile profile, // return true if supported
int * max_width,
int * max_height);
static int dimensionRoundUp(int x)
{
return (x+15) & ~15;
Expand Down
Expand Up @@ -38,10 +38,10 @@ typedef struct
VdpOutputSurfaceQueryPutBitsYCbCrCapabilities *putBitsCapsOutputSurface;
VdpOutputSurfaceGetBitsNative *getBitsNativeOutputSurface;

VdpDecoderCreate *decoderCreate;
VdpDecoderDestroy *decoderDestroy;
VdpDecoderRender *decoderRender;

VdpDecoderCreate *decoderCreate;
VdpDecoderDestroy *decoderDestroy;
VdpDecoderRender *decoderRender;
VdpDecoderQueryCapabilities *queryDecoderCapabilities;

VdpPresentationQueueTargetDestroy *presentationQueueDestroy;
VdpPresentationQueueCreate *presentationQueueCreate;
Expand All @@ -61,6 +61,8 @@ typedef struct
VdpVideoSurfaceGetParameters *mixerGetSurfaceParameters;

VdpPresentationQueueTargetCreateX11 *presentationQueueDisplayX11Create;


}VdpFunctions;

namespace ADM_coreVdpau
Expand Down
Expand Up @@ -142,7 +142,7 @@ bool admVdpau::init(GUI_WindowInfo *x)
GetMe(putBitsYV12OutputSurface,VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR);
GetMe(putBitsCapsOutputSurface,VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES);
GetMe(getBitsNativeOutputSurface,VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE);

GetMe(queryDecoderCapabilities,VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES);


GetMe(presentationQueueDestroy,VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY);
Expand Down
Expand Up @@ -259,6 +259,30 @@ VdpStatus admVdpau::mixerSetAttributesValue(VdpVideoMixer mixer,
return e;
}

bool admVdpau::queryDecoderCapabilities(
VdpDecoderProfile profile,
int * maxWidth,
int * maxHeight)
{
VdpBool is_supported=false;
uint32_t max_level,max_macroblocks,max_width,max_height;
VdpStatus e=ADM_coreVdpau::funcs.queryDecoderCapabilities(ADM_coreVdpau::vdpDevice,
profile,
&is_supported,
&max_level,
&max_macroblocks,
&max_width,
&max_height);
if(VDP_STATUS_OK!=e)
{
ADM_warning("queryDecoderCapabilities failed :%s\n",getErrorString(e));
return false;
}
*maxWidth=max_width;
*maxHeight=max_height;
return is_supported;
}

/**
\fn mixerRenderWithPastAndFuture
*/
Expand Down

0 comments on commit 868f24f

Please sign in to comment.