32 #define MAX_SLICES 1024
34 DXVA_PictureParameters
pp;
46 DXVA_PictureParameters *pp)
51 memset(pp, 0,
sizeof(*pp));
53 pp->wDeblockedPictureIndex = 0;
57 pp->wForwardRefPictureIndex = 0xffff;
61 pp->wBackwardRefPictureIndex = 0xffff;
62 pp->wPicWidthInMBminus1 = s->
mb_width - 1;
63 pp->wPicHeightInMBminus1 = (s->
mb_height >> is_field) - 1;
64 pp->bMacroblockWidthMinus1 = 15;
65 pp->bMacroblockHeightMinus1 = 15;
66 pp->bBlockWidthMinus1 = 7;
67 pp->bBlockHeightMinus1 = 7;
73 pp->bBidirectionalAveragingMode = 0;
74 pp->bMVprecisionAndChromaRelation= 0;
76 pp->bPicScanFixed = 1;
78 pp->bPicReadbackRequests = 0;
80 pp->bPicSpatialResid8 = 0;
81 pp->bPicOverflowBlocks = 0;
82 pp->bPicExtrapolation = 0;
83 pp->bPicDeblocked = 0;
84 pp->bPicDeblockConfined = 0;
85 pp->bPic4MVallowed = 0;
89 pp->bReservedBits = 0;
90 pp->wBitstreamFcodes = (s->
mpeg_f_code[0][0] << 12) |
105 pp->bBitstreamConcealmentNeed = 0;
106 pp->bBitstreamConcealmentMethod = 0;
112 DXVA_QmatrixData *qm)
115 for (i = 0; i < 4; i++)
116 qm->bNewQmatrix[i] = 1;
117 for (i = 0; i < 64; i++) {
128 DXVA_SliceInfo *slice,
135 memset(slice, 0,
sizeof(*slice));
136 slice->wHorizontalPosition = s->
mb_x;
137 slice->wVerticalPosition = s->
mb_y >> is_field;
138 slice->dwSliceBitsInBuffer = 8 *
size;
139 slice->dwSliceDataLocation = position;
140 slice->bStartCodeBitOffset = 0;
141 slice->bReservedBits = 0;
144 slice->wBadSliceChopping = 0;
148 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
171 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
175 &dxva_size, &dxva_data_ptr)))
181 type = DXVA2_BitStreamDateBufferType;
184 &dxva_data_ptr, &dxva_size)))
189 dxva_data = dxva_data_ptr;
191 end = dxva_data + dxva_size;
195 unsigned position = slice->dwSliceDataLocation;
196 unsigned size = slice->dwSliceBitsInBuffer / 8;
197 if (size > end - current) {
201 slice->dwSliceDataLocation = current - dxva_data;
204 slice->wNumberMBsInSlice =
205 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
207 slice->wNumberMBsInSlice =
208 mb_count - slice[0].wNumberMBsInSlice;
210 memcpy(current, &ctx_pic->
bitstream[position], size);
228 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
229 memset(dsc11, 0,
sizeof(*dsc11));
230 dsc11->BufferType =
type;
231 dsc11->DataSize = current - dxva_data;
232 dsc11->NumMBsInBuffer = mb_count;
234 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
239 DXVA2_DecodeBufferDesc *dsc2 = bs;
240 memset(dsc2, 0,
sizeof(*dsc2));
241 dsc2->CompressedBufferType =
type;
242 dsc2->DataSize = current - dxva_data;
243 dsc2->NumMBsInBuffer = mb_count;
245 type = DXVA2_SliceControlBufferType;
265 if (!DXVA_CONTEXT_VALID(avctx, ctx))
311 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
312 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
319 #if CONFIG_MPEG2_DXVA2_HWACCEL
321 .
name =
"mpeg2_dxva2",
335 #if CONFIG_MPEG2_D3D11VA_HWACCEL
337 .
name =
"mpeg2_d3d11va",
351 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
353 .
name =
"mpeg2_d3d11va2",
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
uint16_t chroma_intra_matrix[64]
uint16_t chroma_inter_matrix[64]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
DXVA_PictureParameters pp
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
#define D3D11VA_CONTEXT(ctx)
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
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))
static int get_bits_count(const GetBitContext *s)
static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
int mb_height
number of MBs horizontally & vertically
DXVA_SliceInfo slice[MAX_SLICES]
static void fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, const struct MpegEncContext *s, DXVA_PictureParameters *pp)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
#define DXVA2_CONTEXT(ctx)
const char * name
Name of the hardware accelerated codec.
static const chunk_decoder decoder[8]
Picture * current_picture_ptr
pointer to the current picture
void * hwaccel_picture_private
Hardware accelerator private data.
int ff_dxva2_decode_init(AVCodecContext *avctx)
uint8_t idct_permutation[64]
IDCT input permutation.
static void fill_quantization_matrices(AVCodecContext *avctx, AVDXVAContext *ctx, const struct MpegEncContext *s, DXVA_QmatrixData *qm)
static void fill_slice(AVCodecContext *avctx, const struct MpegEncContext *s, DXVA_SliceInfo *slice, unsigned position, const uint8_t *buffer, unsigned size)
preferred ID for MPEG-1/2 video decoding
int first_field
is 1 for the first field of a field picture 0 otherwise
uint16_t inter_matrix[64]
int concealment_motion_vectors
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
main external API structure.
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const uint8_t ff_zigzag_direct[64]
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
Hardware surfaces for Direct3D11.
const uint8_t * bitstream
Picture last_picture
copy of the previous picture structure.
Picture next_picture
copy of the next picture structure.
#define DXVA_CONTEXT(avctx)
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
static int skip_1stop_8data_bits(GetBitContext *gb)
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...