[FFmpeg-devel] [PATCH] Allow mpegvideo_xvmc decoder to be switched to full software decoding.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Mar 27 16:25:42 CEST 2011


This allows selecting software decoding by having get_format return the
appropriate PIX_FMT.
This has little real usage for XvMC but serves as a proof-of-concept
demonstrating how HWACCEL can be implemented without having a separate
codec for each and every HWACCEL format + software decoding, and
XvMC is unfortunately the only one I can currently test.
---
 libavcodec/mpeg12.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 7034a91..9832698 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -70,6 +70,7 @@ static void exchange_uv(MpegEncContext *s);
 static const enum PixelFormat pixfmt_xvmc_mpg2_420[] = {
                                            PIX_FMT_XVMC_MPEG2_IDCT,
                                            PIX_FMT_XVMC_MPEG2_MC,
+                                           PIX_FMT_YUV420P,
                                            PIX_FMT_NONE};
 
 uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
@@ -1217,9 +1218,12 @@ static enum PixelFormat mpeg_get_pixelformat(AVCodecContext *avctx){
     Mpeg1Context *s1 = avctx->priv_data;
     MpegEncContext *s = &s1->mpeg_enc_ctx;
 
-    if(avctx->xvmc_acceleration)
-        return avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);
-    else if(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
+    if(avctx->xvmc_acceleration) {
+        enum PixelFormat res = avctx->get_format(avctx,pixfmt_xvmc_mpg2_420);
+        if (res == PIX_FMT_YUV420P)
+            avctx->xvmc_acceleration = 0;
+        return res;
+    } else if(avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
         if(avctx->codec_id == CODEC_ID_MPEG1VIDEO)
             return PIX_FMT_VDPAU_MPEG1;
         else
-- 
1.7.4.1




More information about the ffmpeg-devel mailing list