Go to the documentation of this file.
23 #include <X11/extensions/XvMC.h>
56 s->pblocks[4] =
s->pblocks[5];
67 const int mb_block_count = 4 + (1 <<
s->chroma_format);
69 cbp <<= 12-mb_block_count;
70 for (
i = 0;
i < mb_block_count;
i++) {
72 s->pblocks[
i] = &
s->block[j++];
91 const int mb_block_count = 4 + (1 <<
s->chroma_format);
100 "Render token doesn't look as expected.\n");
106 "Rendering surface contains %i unprocessed blocks.\n",
117 "Rendering surface doesn't provide enough block structures to work with.\n");
122 render->
flags =
s->first_field ? 0 : XVMC_SECOND_FIELD;
126 switch(
s->pict_type) {
173 XvMCMacroBlock *mv_block;
175 int i, cbp, blocks_per_mb;
177 const int mb_xy =
s->mb_y *
s->mb_stride +
s->mb_x;
189 s->last_dc[2] = 128 <<
s->intra_dc_precision;
198 s->current_picture.qscale_table[mb_xy] =
s->qscale;
201 render = (
struct xvmc_pix_fmt*)
s->current_picture.f->data[2];
210 mv_block->x =
s->mb_x;
211 mv_block->y =
s->mb_y;
212 mv_block->dct_type =
s->interlaced_dct;
214 mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;
216 mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
219 mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_FORWARD;
221 mv_block->PMV[0][0][0] =
s->mv[0][0][0];
222 mv_block->PMV[0][0][1] =
s->mv[0][0][1];
223 mv_block->PMV[1][0][0] =
s->mv[0][1][0];
224 mv_block->PMV[1][0][1] =
s->mv[0][1][1];
227 mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_BACKWARD;
228 mv_block->PMV[0][1][0] =
s->mv[1][0][0];
229 mv_block->PMV[0][1][1] =
s->mv[1][0][1];
230 mv_block->PMV[1][1][0] =
s->mv[1][1][0];
231 mv_block->PMV[1][1][1] =
s->mv[1][1][1];
236 mv_block->motion_type = XVMC_PREDICTION_FRAME;
239 mv_block->motion_type = XVMC_PREDICTION_16x8;
242 mv_block->motion_type = XVMC_PREDICTION_FIELD;
244 mv_block->PMV[0][0][1] <<= 1;
245 mv_block->PMV[1][0][1] <<= 1;
246 mv_block->PMV[0][1][1] <<= 1;
247 mv_block->PMV[1][1][1] <<= 1;
251 mv_block->motion_type = XVMC_PREDICTION_DUAL_PRIME;
254 mv_block->PMV[0][0][0] =
s->mv[0][0][0];
255 mv_block->PMV[0][0][1] =
s->mv[0][0][1] << 1;
257 mv_block->PMV[0][1][0] =
s->mv[0][0][0];
258 mv_block->PMV[0][1][1] =
s->mv[0][0][1] << 1;
260 mv_block->PMV[1][0][0] =
s->mv[0][2][0];
261 mv_block->PMV[1][0][1] =
s->mv[0][2][1] << 1;
263 mv_block->PMV[1][1][0] =
s->mv[0][3][0];
264 mv_block->PMV[1][1][1] =
s->mv[0][3][1] << 1;
267 mv_block->PMV[0][1][0] =
s->mv[0][2][0];
268 mv_block->PMV[0][1][1] =
s->mv[0][2][1];
275 mv_block->motion_vertical_field_select = 0;
279 mv_block->motion_vertical_field_select |=
s->field_select[0][0];
280 mv_block->motion_vertical_field_select |=
s->field_select[1][0] << 1;
281 mv_block->motion_vertical_field_select |=
s->field_select[0][1] << 2;
282 mv_block->motion_vertical_field_select |=
s->field_select[1][1] << 3;
289 if (
s->chroma_format >= 2) {
290 blocks_per_mb = 4 + (1 <<
s->chroma_format);
295 for (
i = 0;
i < blocks_per_mb;
i++) {
297 if (
s->block_last_index[
i] >= 0)
303 for (
i = 4;
i < blocks_per_mb;
i++) {
304 memset(
s->pblocks[
i], 0,
sizeof(*
s->pblocks[
i]));
306 *
s->pblocks[
i][0] = 1 << 10;
309 cbp &= 0xf << (blocks_per_mb - 4);
313 mv_block->coded_block_pattern = cbp;
315 mv_block->macroblock_type &= ~XVMC_MB_TYPE_PATTERN;
317 for (
i = 0;
i < blocks_per_mb;
i++) {
318 if (
s->block_last_index[
i] >= 0) {
321 *
s->pblocks[
i][0] -= 1 << 10;
323 s->idsp.idct(*
s->pblocks[
i]);
330 if (!
s->pack_pblocks) {
332 s->pblocks[
i],
sizeof(*
s->pblocks[
i]));
350 #if CONFIG_MPEG1_XVMC_HWACCEL
352 .
name =
"mpeg1_xvmc",
358 .decode_slice =
NULL,
364 #if CONFIG_MPEG2_XVMC_HWACCEL
366 .
name =
"mpeg2_xvmc",
372 .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_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
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.
#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