25 #define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1) 27 DXVA_PictureParameters
pp;
39 DXVA_PictureParameters *
pp)
44 memset(pp, 0,
sizeof(*pp));
46 pp->wDeblockedPictureIndex = 0;
50 pp->wForwardRefPictureIndex = 0xffff;
54 pp->wBackwardRefPictureIndex = 0xffff;
55 pp->wPicWidthInMBminus1 = s->
mb_width - 1;
56 pp->wPicHeightInMBminus1 = (s->
mb_height >> is_field) - 1;
57 pp->bMacroblockWidthMinus1 = 15;
58 pp->bMacroblockHeightMinus1 = 15;
59 pp->bBlockWidthMinus1 = 7;
60 pp->bBlockHeightMinus1 = 7;
66 pp->bBidirectionalAveragingMode = 0;
67 pp->bMVprecisionAndChromaRelation= 0;
69 pp->bPicScanFixed = 1;
71 pp->bPicReadbackRequests = 0;
73 pp->bPicSpatialResid8 = 0;
74 pp->bPicOverflowBlocks = 0;
75 pp->bPicExtrapolation = 0;
76 pp->bPicDeblocked = 0;
77 pp->bPicDeblockConfined = 0;
78 pp->bPic4MVallowed = 0;
82 pp->bReservedBits = 0;
83 pp->wBitstreamFcodes = (s->
mpeg_f_code[0][0] << 12) |
98 pp->bBitstreamConcealmentNeed = 0;
99 pp->bBitstreamConcealmentMethod = 0;
105 DXVA_QmatrixData *
qm)
108 for (i = 0; i < 4; i++)
109 qm->bNewQmatrix[i] = 1;
110 for (i = 0; i < 64; i++) {
121 DXVA_SliceInfo *
slice,
128 memset(slice, 0,
sizeof(*slice));
129 slice->wHorizontalPosition = s->
mb_x;
130 slice->wVerticalPosition = s->
mb_y >> is_field;
131 slice->dwSliceBitsInBuffer = 8 *
size;
132 slice->dwSliceDataLocation = position;
133 slice->bStartCodeBitOffset = 0;
134 slice->bReservedBits = 0;
137 slice->wBadSliceChopping = 0;
141 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
148 DXVA2_DecodeBufferDesc *bs,
149 DXVA2_DecodeBufferDesc *sc)
162 DXVA2_BitStreamDateBufferType,
163 (
void **)&dxva_data, &dxva_size)))
166 end = dxva_data + dxva_size;
170 unsigned position = slice->dwSliceDataLocation;
171 unsigned size = slice->dwSliceBitsInBuffer / 8;
172 if (size > end - current) {
176 slice->dwSliceDataLocation = current - dxva_data;
179 slice->wNumberMBsInSlice =
180 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
182 slice->wNumberMBsInSlice =
183 mb_count - slice[0].wNumberMBsInSlice;
185 memcpy(current, &ctx_pic->
bitstream[position], size);
189 DXVA2_BitStreamDateBufferType)))
194 memset(bs, 0,
sizeof(*bs));
195 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
196 bs->DataSize = current - dxva_data;
197 bs->NumMBsInBuffer = mb_count;
200 DXVA2_SliceControlBufferType,
259 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
260 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
268 .
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.
DXVA_SliceInfo slice[MAX_SLICES]
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
void * hwaccel_context
Hardware accelerator context.
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)
uint8_t idct_permutation[64]
idct input permutation.
int mb_height
number of MBs horizontally & vertically
AVHWAccel ff_mpeg2_dxva2_hwaccel
static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
void av_log(void *avcl, int level, const char *fmt,...)
int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DXVA2_DecodeBufferDesc *bs, DXVA2_DecodeBufferDesc *slice))
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)
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
unsigned ff_dxva2_get_surface_index(const struct dxva_context *ctx, const Picture *picture)
uint16_t inter_matrix[64]
int concealment_motion_vectors
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
synthesis window for stochastic i
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
DSPContext dsp
pointers for accelerated dsp functions
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
const uint8_t ff_zigzag_direct[64]
Picture last_picture
copy of the previous picture structure.
the buffer and buffer 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 AVFilterBuffer structures They must not be accessed but through references stored in AVFilterBufferRef structures Several references can point to the same buffer
Picture next_picture
copy of the next picture structure.
uint16_t intra_matrix[64]
matrix transmitted in the bitstream
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 ...