[FFmpeg-devel] [PATCH 2/2] CrystalHD: Add AVOption to control packed b-frame bug workaround.

Philip Langdale philipl at overt.org
Thu Apr 21 06:51:21 CEST 2011


Some xvid-in-avi files with packed b-frames trigger strange
hardware behaviour, with the result that the packed frame is
output twice and we need to drop one of them to maintain
correct playback.

However, it turns out that some other files, which seem to use
the same packing mechanism *do not* trigger the duplicate frame,
but do exhibit the missing timestamp behaviour that I was
using to detect the bug. So, worst possible world.

For now, the only way to distinguish the two cases is by hand,
hence this option.

Signed-off-by: Philip Langdale <philipl at overt.org>
---
 libavcodec/crystalhd.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index 7ad7b0b..8de2cc5 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -142,6 +142,7 @@ typedef struct {
 
     /* Options */
     uint32_t sWidth;
+    uint8_t bframe_bug;
 } CHDContext;
 
 static const AVOption options[] = {
@@ -150,6 +151,11 @@ static const AVOption options[] = {
       offsetof(CHDContext, sWidth),
       FF_OPT_TYPE_INT, 0, 0, UINT32_MAX,
       AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, },
+    { "crystalhd_packed_bframe_bug",
+      "Assume the clip is divx/xvid that triggers packed b-frame bug",
+      offsetof(CHDContext, bframe_bug),
+      FF_OPT_TYPE_INT, 0, 0, 1,
+      AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, },
     { NULL, },
 };
 
@@ -744,7 +750,7 @@ static inline CopyRet receive_frame(AVCodecContext *avctx,
             }
 
             if (avctx->codec->id == CODEC_ID_MPEG4 &&
-                output.PicInfo.timeStamp == 0) {
+                output.PicInfo.timeStamp == 0 && priv->bframe_bug) {
                 av_log(avctx, AV_LOG_VERBOSE,
                        "CrystalHD: Not returning packed frame twice.\n");
                 priv->last_picture++;
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list