@ -1,5 +1,5 @@
/*
* Intel MediaSDK QSV based MPEG - 2 decoder
* Intel MediaSDK QSV based MPEG - 2 and VC - 1 decoders
*
* copyright ( c ) 2015 Anton Khirnov
*
@ -36,16 +36,16 @@
# include "qsvdec.h"
# include "qsv.h"
typedef struct QSVMPEG2 Context {
typedef struct QSVOther Context {
AVClass * class ;
QSVContext qsv ;
AVFifoBuffer * packet_fifo ;
AVPacket input_ref ;
} QSVMPEG2 Context ;
} QSVOther Context ;
static void qsv_clear_buffers ( QSVMPEG2 Context * s )
static void qsv_clear_buffers ( QSVOther Context * s )
{
AVPacket pkt ;
while ( av_fifo_size ( s - > packet_fifo ) > = sizeof ( pkt ) ) {
@ -58,7 +58,7 @@ static void qsv_clear_buffers(QSVMPEG2Context *s)
static av_cold int qsv_decode_close ( AVCodecContext * avctx )
{
QSVMPEG2 Context * s = avctx - > priv_data ;
QSVOther Context * s = avctx - > priv_data ;
ff_qsv_decode_close ( & s - > qsv ) ;
@ -71,7 +71,7 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
static av_cold int qsv_decode_init ( AVCodecContext * avctx )
{
QSVMPEG2 Context * s = avctx - > priv_data ;
QSVOther Context * s = avctx - > priv_data ;
int ret ;
s - > packet_fifo = av_fifo_alloc ( sizeof ( AVPacket ) ) ;
@ -89,7 +89,7 @@ fail:
static int qsv_decode_frame ( AVCodecContext * avctx , void * data ,
int * got_frame , AVPacket * avpkt )
{
QSVMPEG2 Context * s = avctx - > priv_data ;
QSVOther Context * s = avctx - > priv_data ;
AVFrame * frame = data ;
int ret ;
@ -134,27 +134,30 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
static void qsv_decode_flush ( AVCodecContext * avctx )
{
QSVMPEG2 Context * s = avctx - > priv_data ;
QSVOther Context * s = avctx - > priv_data ;
qsv_clear_buffers ( s ) ;
ff_qsv_decode_flush ( avctx , & s - > qsv ) ;
}
# define OFFSET(x) offsetof(QSVOtherContext, x)
# define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options [ ] = {
{ " async_depth " , " Internal parallelization depth, the higher the value the higher the latency. " , OFFSET ( qsv . async_depth ) , AV_OPT_TYPE_INT , { . i64 = ASYNC_DEPTH_DEFAULT } , 0 , INT_MAX , VD } ,
{ NULL } ,
} ;
# if CONFIG_MPEG2_QSV_HWACCEL
AVHWAccel ff_mpeg2_qsv_hwaccel = {
. name = " mpeg2_qsv " ,
. type = AVMEDIA_TYPE_VIDEO ,
. id = AV_CODEC_ID_MPEG2VIDEO ,
. pix_fmt = AV_PIX_FMT_QSV ,
} ;
# endif
# define OFFSET(x) offsetof(QSVMPEG2Context, x)
# define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static const AVOption options [ ] = {
{ " async_depth " , " Internal parallelization depth, the higher the value the higher the latency. " , OFFSET ( qsv . async_depth ) , AV_OPT_TYPE_INT , { . i64 = ASYNC_DEPTH_DEFAULT } , 0 , INT_MAX , VD } ,
{ NULL } ,
} ;
static const AVClass class = {
# if CONFIG_MPEG2_QSV_DECODER
static const AVClass mpeg2_qsv_class = {
. class_name = " mpeg2_qsv " ,
. item_name = av_default_item_name ,
. option = options ,
@ -164,7 +167,7 @@ static const AVClass class = {
AVCodec ff_mpeg2_qsv_decoder = {
. name = " mpeg2_qsv " ,
. long_name = NULL_IF_CONFIG_SMALL ( " MPEG-2 video (Intel Quick Sync Video acceleration) " ) ,
. priv_data_size = sizeof ( QSVMPEG2 Context ) ,
. priv_data_size = sizeof ( QSVOther Context ) ,
. type = AVMEDIA_TYPE_VIDEO ,
. id = AV_CODEC_ID_MPEG2VIDEO ,
. init = qsv_decode_init ,
@ -172,8 +175,44 @@ AVCodec ff_mpeg2_qsv_decoder = {
. flush = qsv_decode_flush ,
. close = qsv_decode_close ,
. capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 ,
. priv_class = & class ,
. priv_class = & mpeg2_qsv_class ,
. pix_fmts = ( const enum AVPixelFormat [ ] ) { AV_PIX_FMT_NV12 ,
AV_PIX_FMT_QSV ,
AV_PIX_FMT_NONE } ,
} ;
# endif
# if CONFIG_VC1_QSV_HWACCEL
AVHWAccel ff_vc1_qsv_hwaccel = {
. name = " vc1_qsv " ,
. type = AVMEDIA_TYPE_VIDEO ,
. id = AV_CODEC_ID_VC1 ,
. pix_fmt = AV_PIX_FMT_QSV ,
} ;
# endif
# if CONFIG_VC1_QSV_DECODER
static const AVClass vc1_qsv_class = {
. class_name = " vc1_qsv " ,
. item_name = av_default_item_name ,
. option = options ,
. version = LIBAVUTIL_VERSION_INT ,
} ;
AVCodec ff_vc1_qsv_decoder = {
. name = " vc1_qsv " ,
. long_name = NULL_IF_CONFIG_SMALL ( " VC-1 video (Intel Quick Sync Video acceleration) " ) ,
. priv_data_size = sizeof ( QSVOtherContext ) ,
. type = AVMEDIA_TYPE_VIDEO ,
. id = AV_CODEC_ID_VC1 ,
. init = qsv_decode_init ,
. decode = qsv_decode_frame ,
. flush = qsv_decode_flush ,
. close = qsv_decode_close ,
. capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 ,
. priv_class = & vc1_qsv_class ,
. pix_fmts = ( const enum AVPixelFormat [ ] ) { AV_PIX_FMT_NV12 ,
AV_PIX_FMT_QSV ,
AV_PIX_FMT_NONE } ,
} ;
# endif