29 #define MAX_SLICES 1024 31 DXVA_PictureParameters
pp;
43 DXVA_PictureParameters *
pp)
48 memset(pp, 0,
sizeof(*pp));
50 pp->wDeblockedPictureIndex = 0;
54 pp->wForwardRefPictureIndex = 0xffff;
58 pp->wBackwardRefPictureIndex = 0xffff;
59 pp->wPicWidthInMBminus1 = s->
mb_width - 1;
60 pp->wPicHeightInMBminus1 = (s->
mb_height >> is_field) - 1;
61 pp->bMacroblockWidthMinus1 = 15;
62 pp->bMacroblockHeightMinus1 = 15;
63 pp->bBlockWidthMinus1 = 7;
64 pp->bBlockHeightMinus1 = 7;
70 pp->bBidirectionalAveragingMode = 0;
71 pp->bMVprecisionAndChromaRelation= 0;
73 pp->bPicScanFixed = 1;
75 pp->bPicReadbackRequests = 0;
77 pp->bPicSpatialResid8 = 0;
78 pp->bPicOverflowBlocks = 0;
79 pp->bPicExtrapolation = 0;
80 pp->bPicDeblocked = 0;
81 pp->bPicDeblockConfined = 0;
82 pp->bPic4MVallowed = 0;
86 pp->bReservedBits = 0;
87 pp->wBitstreamFcodes = (s->
mpeg_f_code[0][0] << 12) |
102 pp->bBitstreamConcealmentNeed = 0;
103 pp->bBitstreamConcealmentMethod = 0;
109 DXVA_QmatrixData *
qm)
112 for (i = 0; i < 4; i++)
113 qm->bNewQmatrix[i] = 1;
114 for (i = 0; i < 64; i++) {
125 DXVA_SliceInfo *
slice,
132 memset(slice, 0,
sizeof(*slice));
133 slice->wHorizontalPosition = s->
mb_x;
134 slice->wVerticalPosition = s->
mb_y >> is_field;
135 slice->dwSliceBitsInBuffer = 8 *
size;
136 slice->dwSliceDataLocation = position;
137 slice->bStartCodeBitOffset = 0;
138 slice->bReservedBits = 0;
141 slice->wBadSliceChopping = 0;
145 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
168 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
172 &dxva_size, &dxva_data_ptr)))
178 type = DXVA2_BitStreamDateBufferType;
181 &dxva_data_ptr, &dxva_size)))
186 dxva_data = dxva_data_ptr;
188 end = dxva_data + dxva_size;
192 unsigned position = slice->dwSliceDataLocation;
193 unsigned size = slice->dwSliceBitsInBuffer / 8;
194 if (size > end - current) {
198 slice->dwSliceDataLocation = current - dxva_data;
201 slice->wNumberMBsInSlice =
202 slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
204 slice->wNumberMBsInSlice =
205 mb_count - slice[0].wNumberMBsInSlice;
207 memcpy(current, &ctx_pic->
bitstream[position], size);
225 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
226 memset(dsc11, 0,
sizeof(*dsc11));
227 dsc11->BufferType =
type;
228 dsc11->DataSize = current - dxva_data;
229 dsc11->NumMBsInBuffer = mb_count;
231 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
236 DXVA2_DecodeBufferDesc *dsc2 = bs;
237 memset(dsc2, 0,
sizeof(*dsc2));
238 dsc2->CompressedBufferType =
type;
239 dsc2->DataSize = current - dxva_data;
240 dsc2->NumMBsInBuffer = mb_count;
242 type = DXVA2_SliceControlBufferType;
262 if (!DXVA_CONTEXT_VALID(avctx, ctx))
308 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
309 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
316 #if CONFIG_MPEG2_DXVA2_HWACCEL 318 .
name =
"mpeg2_dxva2",
333 #if CONFIG_MPEG2_D3D11VA_HWACCEL 335 .
name =
"mpeg2_d3d11va",
350 #if CONFIG_MPEG2_D3D11VA2_HWACCEL 352 .
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_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
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.
const AVHWAccel ff_mpeg2_d3d11va2_hwaccel
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
const AVHWAccel ff_mpeg2_d3d11va_hwaccel
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.
const AVHWAccel ff_mpeg2_dxva2_hwaccel
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...