27 #define MAX_SLICES 1024
29 DXVA_PictureParameters
pp;
41 DXVA_PictureParameters *pp)
46 memset(pp, 0,
sizeof(*pp));
48 pp->wDeblockedPictureIndex = 0;
52 pp->wForwardRefPictureIndex = 0xffff;
56 pp->wBackwardRefPictureIndex = 0xffff;
57 pp->wPicWidthInMBminus1 = s->
mb_width - 1;
58 pp->wPicHeightInMBminus1 = (s->
mb_height >> is_field) - 1;
59 pp->bMacroblockWidthMinus1 = 15;
60 pp->bMacroblockHeightMinus1 = 15;
61 pp->bBlockWidthMinus1 = 7;
62 pp->bBlockHeightMinus1 = 7;
68 pp->bBidirectionalAveragingMode = 0;
69 pp->bMVprecisionAndChromaRelation= 0;
71 pp->bPicScanFixed = 1;
73 pp->bPicReadbackRequests = 0;
75 pp->bPicSpatialResid8 = 0;
76 pp->bPicOverflowBlocks = 0;
77 pp->bPicExtrapolation = 0;
78 pp->bPicDeblocked = 0;
79 pp->bPicDeblockConfined = 0;
80 pp->bPic4MVallowed = 0;
84 pp->bReservedBits = 0;
85 pp->wBitstreamFcodes = (s->
mpeg_f_code[0][0] << 12) |
100 pp->bBitstreamConcealmentNeed = 0;
101 pp->bBitstreamConcealmentMethod = 0;
107 DXVA_QmatrixData *qm)
110 for (i = 0; i < 4; i++)
111 qm->bNewQmatrix[i] = 1;
112 for (i = 0; i < 64; i++) {
123 DXVA_SliceInfo *slice,
130 memset(slice, 0,
sizeof(*slice));
131 slice->wHorizontalPosition = s->
mb_x;
132 slice->wVerticalPosition = s->
mb_y >> is_field;
133 slice->dwSliceBitsInBuffer = 8 *
size;
134 slice->dwSliceDataLocation = position;
135 slice->bStartCodeBitOffset = 0;
136 slice->bReservedBits = 0;
139 slice->wBadSliceChopping = 0;
143 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
149 DXVA2_DecodeBufferDesc *bs,
150 DXVA2_DecodeBufferDesc *sc)
164 DXVA2_BitStreamDateBufferType,
165 &dxva_data_ptr, &dxva_size)))
168 dxva_data = dxva_data_ptr;
170 end = dxva_data + dxva_size;
174 unsigned position = slice->dwSliceDataLocation;
175 unsigned size = slice->dwSliceBitsInBuffer / 8;
176 if (size > end - current) {
180 slice->dwSliceDataLocation = current - dxva_data;
183 slice->wNumberMBsInSlice =
184 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
186 slice->wNumberMBsInSlice =
187 mb_count - slice[0].wNumberMBsInSlice;
189 memcpy(current, &ctx_pic->
bitstream[position], size);
193 DXVA2_BitStreamDateBufferType)))
198 memset(bs, 0,
sizeof(*bs));
199 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
200 bs->DataSize = current - dxva_data;
201 bs->NumMBsInBuffer = mb_count;
204 DXVA2_SliceControlBufferType,
265 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
266 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
274 .
name =
"mpeg2_dxva2",
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DXVA2_DecodeBufferDesc *bs, DXVA2_DecodeBufferDesc *sc)
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]
static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
DXVA_PictureParameters pp
const DXVA2_ConfigPictureDecode * cfg
DXVA2 configuration used to create the decoder.
unsigned surface_count
The number of surface in the surface array.
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))
DXVA_SliceInfo slice[MAX_SLICES]
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.
void * hwaccel_context
Hardware accelerator context.
static av_cold int end(AVCodecContext *avctx)
static void fill_picture_parameters(AVCodecContext *avctx, struct dxva_context *ctx, const struct MpegEncContext *s, DXVA_PictureParameters *pp)
static int get_bits_count(const GetBitContext *s)
static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
int mb_height
number of MBs horizontally & vertically
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.
AVHWAccel ff_mpeg2_dxva2_hwaccel
static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
const char * name
Name of the hardware accelerated codec.
Picture * current_picture_ptr
pointer to the current picture
void * hwaccel_picture_private
hardware accelerator private data
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 idct_permutation[64]
IDCT input permutation.
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
main external API structure.
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, ...
const uint8_t * bitstream
Picture last_picture
copy of the previous picture structure.
Picture next_picture
copy of the next picture structure.
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
static int skip_1stop_8data_bits(GetBitContext *gb)
IDirectXVideoDecoder * decoder
DXVA2 decoder object.
static void fill_quantization_matrices(AVCodecContext *avctx, struct dxva_context *ctx, const struct MpegEncContext *s, DXVA_QmatrixData *qm)
This structure is used to provides the necessary configurations and data to the DXVA2 FFmpeg HWAccel ...