Go to the documentation of this file.
23 #include "config_components.h"
32 #define MAX_SLICES 1024
35 DXVA_PictureParameters
pp;
45 DXVA_PictureParameters *pp)
48 const Picture *current_picture =
s->current_picture_ptr;
59 memset(pp, 0,
sizeof(*pp));
60 pp->wDecodedPictureIndex =
65 pp->wForwardRefPictureIndex = 0xffff;
69 pp->wBackwardRefPictureIndex = 0xffff;
72 pp->wPicWidthInMBminus1 = avctx->
width - 1;
73 pp->wPicHeightInMBminus1= avctx->
height - 1;
76 pp->wPicWidthInMBminus1 =
s->mb_width - 1;
77 pp->wPicHeightInMBminus1=
s->mb_height - 1;
79 pp->bMacroblockWidthMinus1 = 15;
80 pp->bMacroblockHeightMinus1 = 15;
81 pp->bBlockWidthMinus1 = 7;
82 pp->bBlockHeightMinus1 = 7;
85 pp->bPicStructure |= 0x01;
87 pp->bPicStructure |= 0x02;
91 pp->bBidirectionalAveragingMode = (1 << 7) |
92 ((DXVA_CONTEXT_CFG_INTRARESID(avctx,
ctx) != 0) << 6) |
93 ((DXVA_CONTEXT_CFG_RESIDACCEL(avctx,
ctx) != 0) << 5) |
99 (!
s->quarter_sample );
101 DXVA_CONTEXT_REPORT_ID(avctx,
ctx)++;
102 if (DXVA_CONTEXT_REPORT_ID(avctx,
ctx) >= (1 << 16))
103 DXVA_CONTEXT_REPORT_ID(avctx,
ctx) = 1;
104 pp->bPicScanFixed = DXVA_CONTEXT_REPORT_ID(avctx,
ctx) >> 8;
105 pp->bPicScanMethod = DXVA_CONTEXT_REPORT_ID(avctx,
ctx) & 0xff;
106 pp->bPicReadbackRequests = 0;
107 pp->bRcontrol = v->
rnd;
110 (
s->loop_filter << 5) |
121 pp->bPicDeblocked = ((!pp->bPicBackwardPrediction && v->
overlap) << 6) |
123 (
s->loop_filter << 1);
143 pp->bReservedBits = v->
pq;
147 pp->wBitstreamPCEelements = v->
lumshift;
149 pp->wBitstreamFcodes = 32;
150 pp->wBitstreamPCEelements = 0;
158 pp->wBitstreamFcodes = (32 << 8) | 32;
159 pp->wBitstreamPCEelements = 0;
162 pp->bBitstreamConcealmentNeed = 0;
163 pp->bBitstreamConcealmentMethod = 0;
167 unsigned position,
unsigned size)
172 memset(slice, 0,
sizeof(*slice));
173 slice->wHorizontalPosition = 0;
174 slice->wVerticalPosition =
s->mb_y;
175 slice->dwSliceBitsInBuffer = 8 *
size;
176 slice->dwSliceDataLocation = position;
177 slice->bStartCodeBitOffset = 0;
181 slice->wNumberMBsInSlice = (
s->mb_y >> v->
field_mode) *
s->mb_width +
s->mb_x;
182 slice->wQuantizerScaleCode = v->
pq;
183 slice->wBadSliceChopping = 0;
195 static const uint8_t
start_code[] = { 0, 0, 1, 0x0d };
197 const unsigned mb_count =
s->mb_width * (
s->mb_height >> v->
field_mode);
200 uint8_t *dxva_data, *current, *end;
208 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
212 &dxva_size, &dxva_data_ptr)))
218 type = DXVA2_BitStreamDateBufferType;
221 &dxva_data_ptr, &dxva_size)))
226 dxva_data = dxva_data_ptr;
228 end = dxva_data + dxva_size;
231 unsigned position,
size;
233 position =
slice->dwSliceDataLocation;
235 if (start_code_size +
size > end - current) {
239 slice->dwSliceDataLocation = current - dxva_data;
242 slice->wNumberMBsInSlice =
243 slice[1].wNumberMBsInSlice -
slice[0].wNumberMBsInSlice;
245 slice->wNumberMBsInSlice =
246 mb_count -
slice[0].wNumberMBsInSlice;
249 if (start_code_size) {
256 current += start_code_size;
257 slice->dwSliceBitsInBuffer += start_code_size * 8;
263 padding =
FFMIN(128 - ((current - dxva_data) & 127), end - current);
264 if (
slice && padding > 0) {
265 memset(current, 0, padding);
267 slice->dwSliceBitsInBuffer += padding * 8;
285 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
286 memset(dsc11, 0,
sizeof(*dsc11));
287 dsc11->BufferType =
type;
288 dsc11->DataSize = current - dxva_data;
289 dsc11->NumMBsInBuffer = mb_count;
291 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
296 DXVA2_DecodeBufferDesc *dsc2 = bs;
297 memset(dsc2, 0,
sizeof(*dsc2));
298 dsc2->CompressedBufferType =
type;
299 dsc2->DataSize = current - dxva_data;
300 dsc2->NumMBsInBuffer = mb_count;
302 type = DXVA2_SliceControlBufferType;
321 if (!DXVA_CONTEXT_VALID(avctx,
ctx))
373 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
379 #if CONFIG_WMV3_DXVA2_HWACCEL
381 .
p.
name =
"wmv3_dxva2",
396 #if CONFIG_VC1_DXVA2_HWACCEL
398 .
p.
name =
"vc1_dxva2",
413 #if CONFIG_WMV3_D3D11VA_HWACCEL
415 .
p.
name =
"wmv3_d3d11va",
430 #if CONFIG_WMV3_D3D11VA2_HWACCEL
432 .
p.
name =
"wmv3_d3d11va2",
447 #if CONFIG_VC1_D3D11VA_HWACCEL
449 .
p.
name =
"vc1_d3d11va",
464 #if CONFIG_VC1_D3D11VA2_HWACCEL
466 .
p.
name =
"vc1_d3d11va2",
uint8_t lumscale2
for interlaced field P picture
@ PROGRESSIVE
in the bitstream is reported as 00b
int overlap
overlapped transforms in use
int interlace
Progressive/interlaced (RPTFTM syntax element)
@ ILACE_FRAME
in the bitstream is reported as 10b
static int dxva2_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
static int get_bits_count(const GetBitContext *s)
AVHWAccel p
The public AVHWAccel.
@ MV_PMODE_1MV_HPEL_BILIN
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 fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
@ MV_PMODE_INTENSITY_COMP
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
#define PICT_BOTTOM_FIELD
const struct FFHWAccel ff_wmv3_d3d11va_hwaccel
static const chunk_decoder decoder[8]
@ ILACE_FIELD
in the bitstream is reported as 11b
int multires
frame-level RESPIC syntax element present
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int dxva2_vc1_end_frame(AVCodecContext *avctx)
int dquant
How qscale varies with MBs, 2 bits (not in Simple)
int refdist
distance of the current picture from reference
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define DXVA2_CONTEXT(ctx)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
int postprocflag
Per-frame processing suggestion flag present.
#define DXVA_CONTEXT(avctx)
int rangered
RANGEREDFRM (range reduction) syntax element present at frame level.
void * hwaccel_picture_private
RefStruct reference for hardware accelerator private data.
uint8_t mv_mode
Frame decoding info for all profiles.
int ff_dxva2_decode_init(AVCodecContext *avctx)
uint8_t lumscale
Luma compensation parameters.
int field_mode
1 for interlaced field pictures
int panscanflag
NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present.
@ AV_PICTURE_TYPE_I
Intra.
int resync_marker
could this stream contain resync markers
int refdist_flag
REFDIST syntax element present in II, IP, PI or PP field picture headers.
uint8_t mv_mode2
Secondary MV coding mode (B-frames)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
int chromaformat
2 bits, 2=4:2:0, only defined
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
int tfcntrflag
TFCNTR present.
const char * name
Name of the hardware accelerated codec.
Picture * current_picture_ptr
pointer to the current picture
#define D3D11VA_CONTEXT(ctx)
#define i(width, name, range_min, range_max)
const struct FFHWAccel ff_vc1_d3d11va2_hwaccel
int extended_mv
Ext MV in P/B (not in Simple)
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
static void fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, const VC1Context *v, DXVA_PictureParameters *pp)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
const struct FFHWAccel ff_wmv3_dxva2_hwaccel
DXVA_SliceInfo slice[MAX_SLICES]
const uint8_t * bitstream
main external API structure.
uint8_t bfraction_lut_index
Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[])
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags.
int vstransform
variable-size [48]x[48] transform type + info
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
@ AV_PICTURE_TYPE_P
Predicted.
int ff_dxva2_decode_uninit(AVCodecContext *avctx)
int psf
Progressive Segmented Frame.
#define avpriv_request_sample(...)
const struct FFHWAccel ff_vc1_d3d11va_hwaccel
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
int broadcast
TFF/RFF present.
const struct FFHWAccel ff_vc1_dxva2_hwaccel
static int dxva2_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
int width
picture width / height.
int finterpflag
INTERPFRM present.
int quantizer_mode
2 bits, quantizer mode used for sequence, see QUANT_*
int extended_dmv
Additional extended dmv range at P/B-frame-level.
static void fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, unsigned size)