23#include "config_components.h"
33 DXVA_PicParams_VP9
pp;
47 DXVA_PicParams_VP9 *pp)
56 memset(pp, 0,
sizeof(*pp));
58 pp->profile =
h->h.profile;
59 pp->wFormatAndPictureInfoFlags = ((
h->h.keyframe == 0) << 0) |
60 ((
h->h.invisible == 0) << 1) |
61 (
h->h.errorres << 2) |
65 (
h->h.refreshctx << 6) |
66 (
h->h.parallelmode << 7) |
67 (
h->h.intraonly << 8) |
68 (
h->h.framectxid << 9) |
69 (
h->h.resetctx << 11) |
70 ((
h->h.keyframe ? 0 :
h->h.highprecisionmvs) << 13) |
73 pp->width = avctx->
width;
74 pp->height = avctx->
height;
75 pp->BitDepthMinus8Luma = pixdesc->
comp[0].
depth - 8;
76 pp->BitDepthMinus8Chroma = pixdesc->
comp[1].
depth - 8;
78 pp->interp_filter =
h->h.filtermode ^ (
h->h.filtermode <= 1);
79 pp->Reserved8Bits = 0;
81 for (
i = 0;
i < 8;
i++) {
84 pp->ref_frame_coded_width[
i] =
h->refs[
i].f->width;
85 pp->ref_frame_coded_height[
i] =
h->refs[
i].f->height;
87 pp->ref_frame_map[
i].bPicEntry = 0xFF;
90 for (
i = 0;
i < 3;
i++) {
91 uint8_t refidx =
h->h.refidx[
i];
92 if (
h->refs[refidx].f)
95 pp->frame_refs[
i].bPicEntry = 0xFF;
97 pp->ref_frame_sign_bias[
i + 1] =
h->h.signbias[
i];
102 pp->filter_level =
h->h.filter.level;
103 pp->sharpness_level =
h->h.filter.sharpness;
105 pp->wControlInfoFlags = (
h->h.lf_delta.enabled << 0) |
106 (
h->h.lf_delta.updated << 1) |
107 (
h->h.use_last_frame_mvs << 2) |
110 for (
i = 0;
i < 4;
i++)
111 pp->ref_deltas[
i] =
h->h.lf_delta.ref[
i];
113 for (
i = 0;
i < 2;
i++)
114 pp->mode_deltas[
i] =
h->h.lf_delta.mode[
i];
116 pp->base_qindex =
h->h.yac_qi;
117 pp->y_dc_delta_q =
h->h.ydc_qdelta;
118 pp->uv_dc_delta_q =
h->h.uvdc_qdelta;
119 pp->uv_ac_delta_q =
h->h.uvac_qdelta;
122 pp->stVP9Segments.wSegmentInfoFlags = (
h->h.segmentation.enabled << 0) |
123 (
h->h.segmentation.update_map << 1) |
124 (
h->h.segmentation.temporal << 2) |
125 (
h->h.segmentation.absolute_vals << 3) |
128 for (
i = 0;
i < 7;
i++)
129 pp->stVP9Segments.tree_probs[
i] =
h->h.segmentation.prob[
i];
131 if (
h->h.segmentation.temporal)
132 for (
i = 0;
i < 3;
i++)
133 pp->stVP9Segments.pred_probs[
i] =
h->h.segmentation.pred_prob[
i];
135 memset(pp->stVP9Segments.pred_probs, 255,
sizeof(pp->stVP9Segments.pred_probs));
137 for (
i = 0;
i < 8;
i++) {
138 pp->stVP9Segments.feature_mask[
i] = (
h->h.segmentation.feat[
i].q_enabled << 0) |
139 (
h->h.segmentation.feat[
i].lf_enabled << 1) |
140 (
h->h.segmentation.feat[
i].ref_enabled << 2) |
141 (
h->h.segmentation.feat[
i].skip_enabled << 3);
143 pp->stVP9Segments.feature_data[
i][0] =
h->h.segmentation.feat[
i].q_val;
144 pp->stVP9Segments.feature_data[
i][1] =
h->h.segmentation.feat[
i].lf_val;
145 pp->stVP9Segments.feature_data[
i][2] =
h->h.segmentation.feat[
i].ref_val;
146 pp->stVP9Segments.feature_data[
i][3] = 0;
149 pp->log2_tile_cols =
h->h.tiling.log2_tile_cols;
150 pp->log2_tile_rows =
h->h.tiling.log2_tile_rows;
152 pp->uncompressed_header_size_byte_aligned =
h->h.uncompressed_header_size;
153 pp->first_partition_size =
h->h.compressed_header_size;
160 unsigned position,
unsigned size)
162 memset(slice, 0,
sizeof(*slice));
163 slice->BSNALunitDataLocation = position;
164 slice->SliceBytesInBuffer =
size;
165 slice->wBadSliceChopping = 0;
175 void *dxva_data_ptr =
NULL;
183 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
187 &dxva_size, &dxva_data_ptr)))
193 type = DXVA2_BitStreamDateBufferType;
196 &dxva_data_ptr, &dxva_size)))
201 dxva_data = dxva_data_ptr;
203 if (!dxva_data || ctx_pic->
slice.SliceBytesInBuffer > dxva_size) {
208 memcpy(dxva_data, ctx_pic->
bitstream, ctx_pic->
slice.SliceBytesInBuffer);
210 padding =
FFMIN(128 - ((ctx_pic->
slice.SliceBytesInBuffer) & 127), dxva_size - ctx_pic->
slice.SliceBytesInBuffer);
212 memset(dxva_data + ctx_pic->
slice.SliceBytesInBuffer, 0, padding);
213 ctx_pic->
slice.SliceBytesInBuffer += padding;
229 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
230 memset(dsc11, 0,
sizeof(*dsc11));
231 dsc11->BufferType =
type;
232 dsc11->DataSize = ctx_pic->
slice.SliceBytesInBuffer;
233 dsc11->NumMBsInBuffer = 0;
235 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
240 DXVA2_DecodeBufferDesc *dsc2 = bs;
241 memset(dsc2, 0,
sizeof(*dsc2));
242 dsc2->CompressedBufferType =
type;
243 dsc2->DataSize = ctx_pic->
slice.SliceBytesInBuffer;
244 dsc2->NumMBsInBuffer = 0;
246 type = DXVA2_SliceControlBufferType;
306 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
312#if CONFIG_VP9_DXVA2_HWACCEL
314 .p.name =
"vp9_dxva2",
329#if CONFIG_VP9_D3D11VA_HWACCEL
331 .p.name =
"vp9_d3d11va",
346#if CONFIG_VP9_D3D11VA2_HWACCEL
348 .p.name =
"vp9_d3d11va2",
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, AVDXVAContext *ctx, const AVFrame *frame, int curr)
int ff_dxva2_decode_init(AVCodecContext *avctx)
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
int ff_dxva2_decode_uninit(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))
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
#define DXVA_CONTEXT(avctx)
#define DXVA2_CONTEXT(ctx)
#define D3D11VA_CONTEXT(ctx)
#define DXVA_CONTEXT_REPORT_ID(avctx, ctx)
#define DXVA_CONTEXT_VALID(avctx, ctx)
static void fill_slice_short(DXVA_Slice_VPx_Short *slice, unsigned position, unsigned size)
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
int ff_dxva2_vp9_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_VP9 *pp)
static void fill_picture_entry(DXVA_PicEntry_VPx *pic, unsigned index, unsigned flag)
static int dxva2_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
static int dxva2_vp9_start_frame(AVCodecContext *avctx, av_unused const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
static int dxva2_vp9_end_frame(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const struct FFHWAccel ff_vp9_d3d11va2_hwaccel
const struct FFHWAccel ff_vp9_d3d11va_hwaccel
const struct FFHWAccel ff_vp9_dxva2_hwaccel
static const chunk_decoder decoder[8]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
A reference to a data buffer.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
int depth
Number of bits in the component.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
DXVA_Slice_VPx_Short slice
const uint8_t * bitstream