23 #include "libavutil/log.h"
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);
150 DXVA2_DecodeBufferDesc *bs,
151 DXVA2_DecodeBufferDesc *sc)
159 uint8_t *dxva_data, *current, *end;
163 if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->
decoder,
164 DXVA2_BitStreamDateBufferType,
165 &dxva_data, &dxva_size)))
168 end = dxva_data + dxva_size;
172 unsigned position = slice->dwSliceDataLocation;
173 unsigned size = slice->dwSliceBitsInBuffer / 8;
174 if (size > end - current) {
178 slice->dwSliceDataLocation = current - dxva_data;
181 slice->wNumberMBsInSlice =
182 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
184 slice->wNumberMBsInSlice =
185 mb_count - slice[0].wNumberMBsInSlice;
187 memcpy(current, &ctx_pic->
bitstream[position], size);
190 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->
decoder,
191 DXVA2_BitStreamDateBufferType)))
196 memset(bs, 0,
sizeof(*bs));
197 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
198 bs->DataSize = current - dxva_data;
199 bs->NumMBsInBuffer = mb_count;
202 DXVA2_SliceControlBufferType,
263 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
264 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
272 .
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]
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
DXVA_PictureParameters pp
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.
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)
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)
const DXVA2_ConfigPictureDecode * cfg
DXVA2 configuration used to create the decoder.
uint8_t idct_permutation[64]
IDCT input permutation.
const char * name
Name of the hardware accelerated codec.
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
void * hwaccel_context
Hardware accelerator context.
main external API structure.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const uint8_t ff_zigzag_direct[64]
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 void fill_quantization_matrices(AVCodecContext *avctx, struct dxva_context *ctx, const struct MpegEncContext *s, DXVA_QmatrixData *qm)
IDirectXVideoDecoder * decoder
DXVA2 decoder object.
This structure is used to provides the necessary configurations and data to the DXVA2 Libav HWAccel i...
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...