diff options
Diffstat (limited to 'libavcodec/mpegvideo_xvmc.c')
-rw-r--r-- | libavcodec/mpegvideo_xvmc.c | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/libavcodec/mpegvideo_xvmc.c b/libavcodec/mpegvideo_xvmc.c index a8e068b76c..7d7f7ecb9f 100644 --- a/libavcodec/mpegvideo_xvmc.c +++ b/libavcodec/mpegvideo_xvmc.c @@ -2,20 +2,20 @@ * XVideo Motion Compensation * Copyright (c) 2003 Ivan Kalvachev * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -33,8 +33,6 @@ #include "xvmc_internal.h" #include "version.h" -#if FF_API_XVMC - /** * Initialize the block field of the MpegEncContext pointer passed as * parameter after making sure that the data is not corrupted. @@ -50,6 +48,15 @@ void ff_xvmc_init_block(MpegEncContext *s) s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64); } +static void exchange_uv(MpegEncContext *s) +{ + int16_t (*tmp)[64]; + + tmp = s->pblocks[4]; + s->pblocks[4] = s->pblocks[5]; + s->pblocks[5] = tmp; +} + /** * Fill individual block pointers, so there are no gaps in the data_block array * in case not all blocks in the macroblock are coded. @@ -67,6 +74,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) s->pblocks[i] = NULL; cbp += cbp; } + if (s->swap_uv) { + exchange_uv(s); + } } /** @@ -74,8 +84,9 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp) * This function should be called for every new field and/or frame. * It should be safe to call the function a few times for the same field. */ -int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx) +static int ff_xvmc_field_start(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + struct MpegEncContext *s = avctx->priv_data; struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; const int mb_block_count = 4 + (1 << s->chroma_format); @@ -142,20 +153,22 @@ return -1; * some leftover blocks, for example from error_resilience(), may remain. * It should be safe to call the function a few times for the same field. */ -void ff_xvmc_field_end(MpegEncContext *s) +static int ff_xvmc_field_end(AVCodecContext *avctx) { + struct MpegEncContext *s = avctx->priv_data; struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2]; assert(render); if (render->filled_mv_blocks_num > 0) ff_mpeg_draw_horiz_band(s, 0, 0); + return 0; } /** * Synthesize the data needed by XvMC to render one macroblock of data. * Fill all relevant fields, if necessary do IDCT. */ -void ff_xvmc_decode_mb(MpegEncContext *s) +static void ff_xvmc_decode_mb(struct MpegEncContext *s) { XvMCMacroBlock *mv_block; struct xvmc_pix_fmt *render; @@ -314,7 +327,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s) * slowdown. */ } // copy blocks only if the codec doesn't support pblocks reordering - if (s->avctx->xvmc_acceleration == 1) { + if (!s->pack_pblocks) { memcpy(&render->data_blocks[render->next_free_data_block_num*64], s->pblocks[i], sizeof(*s->pblocks[i])); } @@ -334,4 +347,30 @@ void ff_xvmc_decode_mb(MpegEncContext *s) ff_mpeg_draw_horiz_band(s, 0, 0); } -#endif /* FF_API_XVMC */ +#if CONFIG_MPEG1_XVMC_HWACCEL +AVHWAccel ff_mpeg1_xvmc_hwaccel = { + .name = "mpeg1_xvmc", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG1VIDEO, + .pix_fmt = AV_PIX_FMT_XVMC, + .start_frame = ff_xvmc_field_start, + .end_frame = ff_xvmc_field_end, + .decode_slice = NULL, + .decode_mb = ff_xvmc_decode_mb, + .priv_data_size = 0, +}; +#endif + +#if CONFIG_MPEG2_XVMC_HWACCEL +AVHWAccel ff_mpeg2_xvmc_hwaccel = { + .name = "mpeg2_xvmc", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_MPEG2VIDEO, + .pix_fmt = AV_PIX_FMT_XVMC, + .start_frame = ff_xvmc_field_start, + .end_frame = ff_xvmc_field_end, + .decode_slice = NULL, + .decode_mb = ff_xvmc_decode_mb, + .priv_data_size = 0, +}; +#endif |