FFmpeg
Data Structures | Functions | Variables
vaapi_h264.c File Reference
#include "h264dec.h"
#include "h264_ps.h"
#include "hwaccel.h"
#include "vaapi_decode.h"

Go to the source code of this file.

Data Structures

struct  DPB
 Decoded Picture Buffer (DPB). More...
 

Functions

static void init_vaapi_pic (VAPictureH264 *va_pic)
 Initialize an empty VA API picture. More...
 
static void fill_vaapi_pic (VAPictureH264 *va_pic, const H264Picture *pic, int pic_structure)
 Translate an FFmpeg Picture into its VA API form. More...
 
static int dpb_add (DPB *dpb, const H264Picture *pic)
 Append picture to the decoded picture buffer, in a VA API form that merges the second field picture attributes with the first, if available. More...
 
static int fill_vaapi_ReferenceFrames (VAPictureParameterBufferH264 *pic_param, const H264Context *h)
 Fill in VA API reference frames array. More...
 
static void fill_vaapi_RefPicList (VAPictureH264 RefPicList[32], const H264Ref *ref_list, unsigned int ref_count)
 Fill in VA API reference picture lists from the FFmpeg reference picture list. More...
 
static void fill_vaapi_plain_pred_weight_table (const H264Context *h, int list, unsigned char *luma_weight_flag, short luma_weight[32], short luma_offset[32], unsigned char *chroma_weight_flag, short chroma_weight[32][2], short chroma_offset[32][2])
 Fill in prediction weight table. More...
 
static int vaapi_h264_start_frame (AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
 Initialize and start decoding a frame with VA API. More...
 
static int vaapi_h264_end_frame (AVCodecContext *avctx)
 End a hardware decoding based frame. More...
 
static int vaapi_h264_decode_slice (AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
 Decode the given H.264 slice with VA API. More...
 

Variables

const AVHWAccel ff_h264_vaapi_hwaccel
 

Detailed Description

This file implements the glue code between FFmpeg's and VA API's structures for H.264 decoding.

Definition in file vaapi_h264.c.

Function Documentation

◆ init_vaapi_pic()

static void init_vaapi_pic ( VAPictureH264 *  va_pic)
static

Initialize an empty VA API picture.

VA API requires a fixed-size reference picture array.

Definition at line 39 of file vaapi_h264.c.

Referenced by fill_vaapi_ReferenceFrames(), and fill_vaapi_RefPicList().

◆ fill_vaapi_pic()

static void fill_vaapi_pic ( VAPictureH264 *  va_pic,
const H264Picture pic,
int  pic_structure 
)
static

Translate an FFmpeg Picture into its VA API form.

Parameters
[out]va_picA pointer to VA API's own picture struct
[in]picA pointer to the FFmpeg picture struct to convert
[in]pic_structureThe picture field type (as defined in mpegvideo.h), supersedes pic's field type if nonzero.

Definition at line 55 of file vaapi_h264.c.

Referenced by dpb_add(), fill_vaapi_RefPicList(), and vaapi_h264_start_frame().

◆ dpb_add()

static int dpb_add ( DPB dpb,
const H264Picture pic 
)
static

Append picture to the decoded picture buffer, in a VA API form that merges the second field picture attributes with the first, if available.

The decoded picture buffer's size must be large enough to receive the new VA API picture object.

Definition at line 94 of file vaapi_h264.c.

Referenced by fill_vaapi_ReferenceFrames().

◆ fill_vaapi_ReferenceFrames()

static int fill_vaapi_ReferenceFrames ( VAPictureParameterBufferH264 *  pic_param,
const H264Context h 
)
static

Fill in VA API reference frames array.

Definition at line 125 of file vaapi_h264.c.

Referenced by vaapi_h264_start_frame().

◆ fill_vaapi_RefPicList()

static void fill_vaapi_RefPicList ( VAPictureH264  RefPicList[32],
const H264Ref ref_list,
unsigned int  ref_count 
)
static

Fill in VA API reference picture lists from the FFmpeg reference picture list.

Parameters
[out]RefPicListVA API internal reference picture list
[in]ref_listA pointer to the FFmpeg reference list
[in]ref_countThe number of reference pictures in ref_list

Definition at line 159 of file vaapi_h264.c.

Referenced by vaapi_h264_decode_slice().

◆ fill_vaapi_plain_pred_weight_table()

static void fill_vaapi_plain_pred_weight_table ( const H264Context h,
int  list,
unsigned char *  luma_weight_flag,
short  luma_weight[32],
short  luma_offset[32],
unsigned char *  chroma_weight_flag,
short  chroma_weight[32][2],
short  chroma_offset[32][2] 
)
static

Fill in prediction weight table.

VA API requires a plain prediction weight table as it does not infer any value.

Parameters
[in]hA pointer to the current H.264 context
[in]listThe reference frame list index to use
[out]luma_weight_flagVA API plain luma weight flag
[out]luma_weightVA API plain luma weight table
[out]luma_offsetVA API plain luma offset table
[out]chroma_weight_flagVA API plain chroma weight flag
[out]chroma_weightVA API plain chroma weight table
[out]chroma_offsetVA API plain chroma offset table

Definition at line 188 of file vaapi_h264.c.

Referenced by vaapi_h264_decode_slice().

◆ vaapi_h264_start_frame()

static int vaapi_h264_start_frame ( AVCodecContext avctx,
av_unused const uint8_t buffer,
av_unused uint32_t  size 
)
static

Initialize and start decoding a frame with VA API.

Definition at line 226 of file vaapi_h264.c.

◆ vaapi_h264_end_frame()

static int vaapi_h264_end_frame ( AVCodecContext avctx)
static

End a hardware decoding based frame.

Definition at line 310 of file vaapi_h264.c.

◆ vaapi_h264_decode_slice()

static int vaapi_h264_decode_slice ( AVCodecContext avctx,
const uint8_t buffer,
uint32_t  size 
)
static

Decode the given H.264 slice with VA API.

Definition at line 328 of file vaapi_h264.c.

Variable Documentation

◆ ff_h264_vaapi_hwaccel

const AVHWAccel ff_h264_vaapi_hwaccel
Initial value:
= {
.name = "h264_vaapi",
.pix_fmt = AV_PIX_FMT_VAAPI,
.start_frame = &vaapi_h264_start_frame,
.end_frame = &vaapi_h264_end_frame,
.decode_slice = &vaapi_h264_decode_slice,
.frame_priv_data_size = sizeof(VAAPIDecodePicture),
.frame_params = &ff_vaapi_common_frame_params,
.priv_data_size = sizeof(VAAPIDecodeContext),
.caps_internal = HWACCEL_CAP_ASYNC_SAFE,
}

Definition at line 388 of file vaapi_h264.c.

HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Definition: hwaccel.h:26
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
VAAPIDecodeContext
Definition: vaapi_decode.h:55
VAAPIDecodePicture
Definition: vaapi_decode.h:44
vaapi_h264_start_frame
static int vaapi_h264_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Initialize and start decoding a frame with VA API.
Definition: vaapi_h264.c:226
vaapi_h264_decode_slice
static int vaapi_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Decode the given H.264 slice with VA API.
Definition: vaapi_h264.c:328
ff_vaapi_decode_init
int ff_vaapi_decode_init(AVCodecContext *avctx)
Definition: vaapi_decode.c:610
ff_vaapi_common_frame_params
int ff_vaapi_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition: vaapi_decode.c:586
ff_vaapi_decode_uninit
int ff_vaapi_decode_uninit(AVCodecContext *avctx)
Definition: vaapi_decode.c:699
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: avcodec.h:245
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Definition: pixfmt.h:122
vaapi_h264_end_frame
static int vaapi_h264_end_frame(AVCodecContext *avctx)
End a hardware decoding based frame.
Definition: vaapi_h264.c:310
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279