29 #define MAX_SLICES 256 32 DXVA_PicParams_HEVC
pp;
43 av_assert0((index & 0x7f) == index && (flag & 0x01) == flag);
44 pic->bPicEntry = index | (flag << 7);
51 if ((pp->RefPicList[i].bPicEntry & 0x7f) == surface_index)
58 DXVA_PicParams_HEVC *
pp)
65 memset(pp, 0,
sizeof(*pp));
88 pp->num_short_term_ref_pic_sets = sps->
nb_st_rps;
151 pp->row_height_minus1[i] = pps->
row_height[i] - 1;
157 pp->pps_tc_offset_div2 = pps->
tc_offset / 2;
159 pp->CurrPicOrderCntVal = h->
poc;
172 pp->PicOrderCntValList[
i] = frame->
poc;
174 pp->RefPicList[
i].bPicEntry = 0xff;
175 pp->PicOrderCntValList[
i] = 0;
179 #define DO_REF_LIST(ref_idx, ref_list) { \ 180 const RefPicList *rpl = &h->rps[ref_idx]; \ 181 for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ref_list); i++) { \ 182 const HEVCFrame *frame = NULL; \ 183 while (!frame && j < rpl->nb_refs) \ 184 frame = rpl->ref[j++]; \ 186 pp->ref_list[i] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, frame->frame)); \ 188 pp->ref_list[i] = 0xff; \ 197 pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;
206 memset(qm, 0,
sizeof(*qm));
207 for (i = 0; i < 6; i++) {
208 for (j = 0; j < 16; j++) {
210 qm->ucScalingLists0[
i][j] = sl->
sl[0][
i][
pos];
213 for (j = 0; j < 64; j++) {
215 qm->ucScalingLists1[
i][j] = sl->
sl[1][
i][
pos];
216 qm->ucScalingLists2[
i][j] = sl->
sl[2][
i][
pos];
219 qm->ucScalingLists3[
i][j] = sl->
sl[3][i * 3][
pos];
222 qm->ucScalingListDCCoefSizeID2[
i] = sl->
sl_dc[0][
i];
224 qm->ucScalingListDCCoefSizeID3[
i] = sl->
sl_dc[1][i * 3];
229 unsigned position,
unsigned size)
231 memset(slice, 0,
sizeof(*slice));
232 slice->BSNALunitDataLocation = position;
233 slice->SliceBytesInBuffer =
size;
234 slice->wBadSliceChopping = 0;
245 DXVA_Slice_HEVC_Short *slice =
NULL;
258 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
259 if (FAILED(ID3D11VideoContext_GetDecoderBuffer(
D3D11VA_CONTEXT(ctx)->video_context,
262 &dxva_size, &dxva_data_ptr)))
268 type = DXVA2_BitStreamDateBufferType;
271 &dxva_data_ptr, &dxva_size)))
276 dxva_data = dxva_data_ptr;
278 end = dxva_data + dxva_size;
282 static const unsigned start_code_size =
sizeof(
start_code);
283 unsigned position,
size;
287 position = slice->BSNALunitDataLocation;
288 size = slice->SliceBytesInBuffer;
289 if (start_code_size + size > end - current) {
294 slice->BSNALunitDataLocation = current - dxva_data;
295 slice->SliceBytesInBuffer = start_code_size +
size;
297 memcpy(current, start_code, start_code_size);
298 current += start_code_size;
300 memcpy(current, &ctx_pic->
bitstream[position], size);
303 padding =
FFMIN(128 - ((current - dxva_data) & 127), end - current);
304 if (slice && padding > 0) {
305 memset(current, 0, padding);
308 slice->SliceBytesInBuffer += padding;
325 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
326 memset(dsc11, 0,
sizeof(*dsc11));
327 dsc11->BufferType =
type;
328 dsc11->DataSize = current - dxva_data;
329 dsc11->NumMBsInBuffer = 0;
331 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
336 DXVA2_DecodeBufferDesc *dsc2 = bs;
337 memset(dsc2, 0,
sizeof(*dsc2));
338 dsc2->CompressedBufferType =
type;
339 dsc2->DataSize = current - dxva_data;
340 dsc2->NumMBsInBuffer = 0;
342 type = DXVA2_SliceControlBufferType;
349 av_assert0(((current - dxva_data) & 127) == 0);
352 slice_data, slice_size, 0);
364 if (!DXVA_CONTEXT_VALID(avctx, ctx))
407 int scale = ctx_pic->
pp.dwCodingParamToolFlags & 1;
414 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
415 scale ? &ctx_pic->
qm :
NULL, scale ?
sizeof(ctx_pic->
qm) : 0,
420 #if CONFIG_HEVC_DXVA2_HWACCEL 422 .
name =
"hevc_dxva2",
437 #if CONFIG_HEVC_D3D11VA_HWACCEL 439 .
name =
"hevc_d3d11va",
454 #if CONFIG_HEVC_D3D11VA2_HWACCEL 456 .
name =
"hevc_d3d11va2",
unsigned int log2_min_cb_size
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
int max_dec_pic_buffering
const uint8_t * bitstream
unsigned int * row_height
RowHeight.
void * hwaccel_picture_private
uint8_t weighted_bipred_flag
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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)
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
#define D3D11VA_CONTEXT(ctx)
uint8_t entropy_coding_sync_enabled_flag
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
#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
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
int ff_dxva2_decode_uninit(AVCodecContext *avctx)
static av_cold int end(AVCodecContext *avctx)
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 *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice))
const uint8_t ff_hevc_diag_scan8x8_x[64]
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
unsigned int log2_min_pcm_cb_size
struct HEVCSPS::@69 temporal_layer[HEVC_MAX_SUB_LAYERS]
DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]
uint8_t scaling_list_data_present_flag
uint8_t loop_filter_disable_flag
uint8_t transquant_bypass_enable_flag
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int log2_max_poc_lsb
#define HEVC_FRAME_FLAG_LONG_REF
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
#define DXVA2_CONTEXT(ctx)
simple assert() macros that are a bit more flexible than ISO C assert().
#define HEVC_FRAME_FLAG_SHORT_REF
static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h, DXVA_PicParams_HEVC *pp)
uint8_t tiles_enabled_flag
uint8_t lists_modification_present_flag
const char * name
Name of the hardware accelerated codec.
int max_transform_hierarchy_depth_inter
static const chunk_decoder decoder[8]
uint8_t cu_qp_delta_enabled_flag
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_dxva2_decode_init(AVCodecContext *avctx)
static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
const uint8_t ff_hevc_diag_scan4x4_y[16]
const AVHWAccel ff_hevc_dxva2_hwaccel
#define FF_ARRAY_ELEMS(a)
uint8_t constrained_intra_pred_flag
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
uint8_t transform_skip_enabled_flag
uint16_t num_tile_columns
num_tile_columns_minus1 + 1
uint8_t uniform_spacing_flag
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
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
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
const AVHWAccel ff_hevc_d3d11va2_hwaccel
uint8_t sps_temporal_mvp_enabled_flag
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
unsigned int log2_min_tb_size
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
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_*.
unsigned int log2_diff_max_min_coding_block_size
unsigned int log2_max_pcm_cb_size
Hardware surfaces for Direct3D11.
const uint8_t ff_hevc_diag_scan4x4_x[16]
int max_transform_hierarchy_depth_intra
#define DO_REF_LIST(ref_idx, ref_list)
uint8_t weighted_pred_flag
uint16_t num_tile_rows
num_tile_rows_minus1 + 1
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
const uint8_t ff_hevc_diag_scan8x8_y[64]
uint8_t sps_strong_intra_smoothing_enable_flag
int rps_idx_num_delta_pocs
#define DXVA_CONTEXT(avctx)
uint8_t long_term_ref_pics_present_flag
int diff_cu_qp_delta_depth
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
const AVHWAccel ff_hevc_d3d11va_hwaccel
static int dxva2_hevc_end_frame(AVCodecContext *avctx)
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
uint8_t dependent_slice_segments_enabled_flag