Go to the documentation of this file.
23 #include <X11/extensions/XvMC.h>
57 s->pblocks[4] =
s->pblocks[5];
68 const int mb_block_count = 4 + (1 <<
s->chroma_format);
70 cbp <<= 12-mb_block_count;
71 for (
i = 0;
i < mb_block_count;
i++) {
73 s->pblocks[
i] = &
s->block[j++];
92 const int mb_block_count = 4 + (1 <<
s->chroma_format);
101 "Render token doesn't look as expected.\n");
107 "Rendering surface contains %i unprocessed blocks.\n",
118 "Rendering surface doesn't provide enough block structures to work with.\n");
123 render->
flags =
s->first_field ? 0 : XVMC_SECOND_FIELD;
127 switch(
s->pict_type) {
174 XvMCMacroBlock *mv_block;
176 int i, cbp, blocks_per_mb;
178 const int mb_xy =
s->mb_y *
s->mb_stride +
s->mb_x;
190 s->last_dc[2] = 128 <<
s->intra_dc_precision;
199 s->current_picture.qscale_table[mb_xy] =
s->qscale;
202 render = (
struct xvmc_pix_fmt*)
s->current_picture.f->data[2];
211 mv_block->x =
s->mb_x;
212 mv_block->y =
s->mb_y;
213 mv_block->dct_type =
s->interlaced_dct;
215 mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;
217 mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
220 mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_FORWARD;
222 mv_block->PMV[0][0][0] =
s->mv[0][0][0];
223 mv_block->PMV[0][0][1] =
s->mv[0][0][1];
224 mv_block->PMV[1][0][0] =
s->mv[0][1][0];
225 mv_block->PMV[1][0][1] =
s->mv[0][1][1];
228 mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_BACKWARD;
229 mv_block->PMV[0][1][0] =
s->mv[1][0][0];
230 mv_block->PMV[0][1][1] =
s->mv[1][0][1];
231 mv_block->PMV[1][1][0] =
s->mv[1][1][0];
232 mv_block->PMV[1][1][1] =
s->mv[1][1][1];
237 mv_block->motion_type = XVMC_PREDICTION_FRAME;
240 mv_block->motion_type = XVMC_PREDICTION_16x8;
243 mv_block->motion_type = XVMC_PREDICTION_FIELD;
245 mv_block->PMV[0][0][1] <<= 1;
246 mv_block->PMV[1][0][1] <<= 1;
247 mv_block->PMV[0][1][1] <<= 1;
248 mv_block->PMV[1][1][1] <<= 1;
252 mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME;
255 mv_block->PMV[0][0][0] =
s->mv[0][0][0];
256 mv_block->PMV[0][0][1] =
s->mv[0][0][1] << 1;
258 mv_block->PMV[0][1][0] =
s->mv[0][0][0];
259 mv_block->PMV[0][1][1] =
s->mv[0][0][1] << 1;
261 mv_block->PMV[1][0][0] =
s->mv[0][2][0];
262 mv_block->PMV[1][0][1] =
s->mv[0][2][1] << 1;
264 mv_block->PMV[1][1][0] =
s->mv[0][3][0];
265 mv_block->PMV[1][1][1] =
s->mv[0][3][1] << 1;
268 mv_block->PMV[0][1][0] =
s->mv[0][2][0];
269 mv_block->PMV[0][1][1] =
s->mv[0][2][1];
276 mv_block->motion_vertical_field_select = 0;
280 mv_block->motion_vertical_field_select |=
s->field_select[0][0];
281 mv_block->motion_vertical_field_select |=
s->field_select[1][0] << 1;
282 mv_block->motion_vertical_field_select |=
s->field_select[0][1] << 2;
283 mv_block->motion_vertical_field_select |=
s->field_select[1][1] << 3;
290 if (
s->chroma_format >= 2) {
291 blocks_per_mb = 4 + (1 <<
s->chroma_format);
296 for (
i = 0;
i < blocks_per_mb;
i++) {
298 if (
s->block_last_index[
i] >= 0)
304 for (
i = 4;
i < blocks_per_mb;
i++) {
305 memset(
s->pblocks[
i], 0,
sizeof(*
s->pblocks[
i]));
307 *
s->pblocks[
i][0] = 1 << 10;
310 cbp &= 0xf << (blocks_per_mb - 4);
314 mv_block->coded_block_pattern = cbp;
316 mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
318 for (
i = 0;
i < blocks_per_mb;
i++) {
319 if (
s->block_last_index[
i] >= 0) {
322 *
s->pblocks[
i][0] -= 1 << 10;
324 s->idsp.idct(*
s->pblocks[
i]);
331 if (!
s->pack_pblocks) {
333 s->pblocks[
i],
sizeof(*
s->pblocks[
i]));
351 #if CONFIG_MPEG1_XVMC_HWACCEL
353 .
name =
"mpeg1_xvmc",
359 .decode_slice =
NULL,
365 #if CONFIG_MPEG2_XVMC_HWACCEL
367 .
name =
"mpeg2_xvmc",
373 .decode_slice =
NULL,
#define MV_TYPE_16X16
1 vector for the whole mb
static void exchange_uv(MpegEncContext *s)
int unsigned_intra
In MoCo mode it indicates that intra macroblocks are assumed to be in unsigned format; same as the XV...
const AVHWAccel ff_mpeg1_xvmc_hwaccel
#define MV_TYPE_16X8
2 vectors, one per 16x8 block
int start_mv_blocks_num
Number of macroblock descriptions in the mv_blocks array that have already been passed to the hardwar...
int filled_mv_blocks_num
Number of new macroblock descriptions in the mv_blocks array (after start_mv_blocks_num) that are fil...
int idct
Indicate that the hardware would interpret data_blocks as IDCT coefficients and perform IDCT on them.
struct AVCodecContext * avctx
int xvmc_id
The field contains the special constant value AV_XVMC_ID.
#define MV_TYPE_DMV
2 vectors, special mpeg2 Dual Prime Vectors
void ff_xvmc_init_block(MpegEncContext *s)
Initialize the block field of the MpegEncContext pointer passed as parameter after making sure that t...
unsigned int flags
XVMC_SECOND_FIELD - 1st or 2nd field in the sequence.
void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
Fill individual block pointers, so there are no gaps in the data_block array in case not all blocks i...
short * data_blocks
Pointer to the block array allocated by XvMCCreateBlocks().
XvMCSurface * p_future_surface
Pointer to the surface used as future reference.
#define AV_XVMC_ID
special value to ensure that regular pixel routines haven't corrupted the struct the number is 1337 s...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int next_free_data_block_num
Number of the next free data block; one data block consists of 64 short values in the data_blocks arr...
int allocated_data_blocks
Number of blocks that can be stored at once in the data_blocks array.
int allocated_mv_blocks
Number of macroblock descriptions that can be stored in the mv_blocks array.
static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Find and store the surfaces that are used as reference frames.
static void ff_xvmc_decode_mb(struct MpegEncContext *s)
Synthesize the data needed by XvMC to render one macroblock of data.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PIX_FMT_XVMC
XVideo Motion Acceleration via common packet passing.
const AVHWAccel ff_mpeg2_xvmc_hwaccel
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
XvMCMacroBlock * mv_blocks
Pointer to the macroblock description array allocated by XvMCCreateMacroBlocks() and freed by XvMCDes...
XvMCSurface * p_past_surface
Set by the decoder before calling ff_draw_horiz_band(), needed by the XvMCRenderSurface function.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
#define MV_TYPE_FIELD
2 vectors, one per field
const char * name
Name of the hardware accelerated codec.
unsigned int picture_structure
top/bottom field or frame
#define i(width, name, range_min, range_max)
main external API structure.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
@ AV_PICTURE_TYPE_P
Predicted.
static int ff_xvmc_field_end(AVCodecContext *avctx)
Complete frame/field rendering by passing any remaining blocks.
XvMCSurface * p_surface
Pointer to the surface allocated by XvMCCreateSurface().
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding