28 #define MAX_SLICES 256
31 DXVA_PicParams_HEVC
pp;
40 unsigned index,
unsigned flag)
42 av_assert0((index & 0x7f) == index && (flag & 0x01) == flag);
43 pic->bPicEntry = index | (flag << 7);
50 if ((pp->RefPicList[i].bPicEntry & 0x7f) == surface_index)
57 DXVA_PicParams_HEVC *pp)
62 memset(pp, 0,
sizeof(*pp));
156 pp->CurrPicOrderCntVal = h->
poc;
159 memset(&pp->RefPicList, 0xff,
sizeof(pp->RefPicList));
160 memset(&pp->RefPicSetStCurrBefore, 0xff,
sizeof(pp->RefPicSetStCurrBefore));
161 memset(&pp->RefPicSetStCurrAfter, 0xff,
sizeof(pp->RefPicSetStCurrAfter));
162 memset(&pp->RefPicSetLtCurr, 0xff,
sizeof(pp->RefPicSetLtCurr));
169 pp->PicOrderCntValList[j] = frame->
poc;
174 #define DO_REF_LIST(ref_idx, ref_list) { \
175 const RefPicList *rpl = &h->rps[ref_idx]; \
176 av_assert0(rpl->nb_refs <= FF_ARRAY_ELEMS(pp->ref_list)); \
177 for (j = 0, k = 0; j < rpl->nb_refs; j++) { \
179 pp->ref_list[k] = get_refpic_index(pp, ff_dxva2_get_surface_index(ctx, rpl->ref[j]->frame)); \
190 pp->StatusReportFeedbackNumber = 1 + ctx->
report_id++;
199 memset(qm, 0,
sizeof(*qm));
200 for (i = 0; i < 6; i++) {
201 for (j = 0; j < 16; j++) {
203 qm->ucScalingLists0[i][j] = sl->
sl[0][i][pos];
206 for (j = 0; j < 64; j++) {
208 qm->ucScalingLists1[i][j] = sl->
sl[1][i][pos];
209 qm->ucScalingLists2[i][j] = sl->
sl[2][i][pos];
212 qm->ucScalingLists3[i][j] = sl->
sl[3][i][pos];
215 qm->ucScalingListDCCoefSizeID2[i] = sl->
sl_dc[0][i];
217 qm->ucScalingListDCCoefSizeID3[i] = sl->
sl_dc[1][i];
222 unsigned position,
unsigned size)
224 memset(slice, 0,
sizeof(*slice));
225 slice->BSNALunitDataLocation = position;
226 slice->SliceBytesInBuffer =
size;
227 slice->wBadSliceChopping = 0;
231 DXVA2_DecodeBufferDesc *bs,
232 DXVA2_DecodeBufferDesc *sc)
238 DXVA_Slice_HEVC_Short *slice =
NULL;
249 DXVA2_BitStreamDateBufferType,
250 &dxva_data_ptr, &dxva_size)))
253 dxva_data = dxva_data_ptr;
255 end = dxva_data + dxva_size;
259 static const unsigned start_code_size =
sizeof(
start_code);
260 unsigned position,
size;
264 position = slice->BSNALunitDataLocation;
265 size = slice->SliceBytesInBuffer;
266 if (start_code_size + size > end - current) {
271 slice->BSNALunitDataLocation = current - dxva_data;
272 slice->SliceBytesInBuffer = start_code_size +
size;
274 memcpy(current, start_code, start_code_size);
275 current += start_code_size;
277 memcpy(current, &ctx_pic->
bitstream[position], size);
280 padding =
FFMIN(128 - ((current - dxva_data) & 127), end - current);
281 if (slice && padding > 0) {
282 memset(current, 0, padding);
285 slice->SliceBytesInBuffer += padding;
288 DXVA2_BitStreamDateBufferType)))
293 memset(bs, 0,
sizeof(*bs));
294 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
295 bs->DataSize = current - dxva_data;
296 bs->NumMBsInBuffer = 0;
303 DXVA2_SliceControlBufferType,
304 slice_data, slice_size, 0);
359 int scale = ctx_pic->
pp.dwCodingParamToolFlags & 1;
366 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
367 scale ? &ctx_pic->
qm :
NULL, scale ?
sizeof(ctx_pic->
qm) : 0,
373 .
name =
"hevc_dxva2",
unsigned int log2_min_cb_size
int max_dec_pic_buffering
const uint8_t * bitstream
unsigned int * row_height
RowHeight.
void * hwaccel_picture_private
const uint8_t ff_hevc_diag_scan4x4_x[16]
uint8_t weighted_bipred_flag
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size)
#define FF_ARRAY_ELEMS(a)
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
const DXVA2_ConfigPictureDecode * cfg
DXVA2 configuration used to create the decoder.
unsigned surface_count
The number of surface in the surface array.
uint8_t entropy_coding_sync_enabled_flag
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DXVA2_DecodeBufferDesc *bs, DXVA2_DecodeBufferDesc *slice))
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index)
unsigned int log2_max_trafo_size
void * hwaccel_context
Hardware accelerator context.
static av_cold int end(AVCodecContext *avctx)
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DXVA2_DecodeBufferDesc *bs, DXVA2_DecodeBufferDesc *sc)
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
unsigned int log2_min_pcm_cb_size
DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]
uint8_t scaling_list_data_present_flag
static void fill_picture_parameters(struct dxva_context *ctx, const HEVCContext *h, DXVA_PicParams_HEVC *pp)
uint8_t loop_filter_disable_flag
static void fill_scaling_lists(struct dxva_context *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
uint8_t transquant_bypass_enable_flag
#define HEVC_FRAME_FLAG_LONG_REF
unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx, const AVFrame *frame)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int log2_max_poc_lsb
struct HEVCSPS::@51 temporal_layer[MAX_SUB_LAYERS]
simple assert() macros that are a bit more flexible than ISO C assert().
uint8_t tiles_enabled_flag
uint8_t lists_modification_present_flag
#define HEVC_FRAME_FLAG_SHORT_REF
const char * name
Name of the hardware accelerated codec.
int max_transform_hierarchy_depth_inter
int num_tile_columns
num_tile_columns_minus1 + 1
uint8_t cu_qp_delta_enabled_flag
int ff_dxva2_commit_buffer(AVCodecContext *avctx, struct dxva_context *ctx, DXVA2_DecodeBufferDesc *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
uint8_t constrained_intra_pred_flag
unsigned report_id
Private to the FFmpeg AVHWAccel implementation.
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
uint8_t transform_skip_enabled_flag
uint8_t uniform_spacing_flag
main external API structure.
int num_extra_slice_header_bits
static void fill_picture_entry(DXVA_PicEntry_HEVC *pic, unsigned index, unsigned flag)
uint8_t loop_filter_across_tiles_enabled_flag
uint8_t num_long_term_ref_pics_sps
uint8_t sps_temporal_mvp_enabled_flag
int num_tile_rows
num_tile_rows_minus1 + 1
const uint8_t ff_hevc_diag_scan8x8_y[64]
AVHWAccel ff_hevc_dxva2_hwaccel
unsigned int log2_min_tb_size
uint8_t scaling_list_enable_flag
int tc_offset
tc_offset_div2 * 2
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
static const uint8_t start_code[]
unsigned int log2_diff_max_min_coding_block_size
unsigned int log2_max_pcm_cb_size
int max_transform_hierarchy_depth_intra
#define DO_REF_LIST(ref_idx, ref_list)
uint8_t weighted_pred_flag
unsigned int * column_width
ColumnWidth.
static int dxva2_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
uint8_t slice_header_extension_present_flag
uint8_t sps_strong_intra_smoothing_enable_flag
uint8_t long_term_ref_pics_present_flag
int diff_cu_qp_delta_depth
const uint8_t ff_hevc_diag_scan8x8_x[64]
static int dxva2_hevc_end_frame(AVCodecContext *avctx)
IDirectXVideoDecoder * decoder
DXVA2 decoder object.
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
static int dxva2_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
const uint8_t ff_hevc_diag_scan4x4_y[16]
This structure is used to provides the necessary configurations and data to the DXVA2 FFmpeg HWAccel ...
uint8_t dependent_slice_segments_enabled_flag