[FFmpeg-cvslog] crystalhd: Fix up the missing first sample

Philip Langdale git at videolan.org
Wed Nov 2 22:50:39 EET 2016


ffmpeg | branch: master | Philip Langdale <philipl at overt.org> | Sat Oct 15 13:30:52 2016 -0700| [234d3cbf469e9feef255e229202d4b029e66e9fe] | committer: Philip Langdale

crystalhd: Fix up the missing first sample

Why on earth the hardware returns garbage for the first sample of
a decoded picture is anyone's guess. The simplest reasonable way
to patch it up is to copy the first sample of the second line. This
should result in the correct chroma values (because the data was
original 4:2:0 upsampled to 4:2:2) even if the luma is isn't.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=234d3cbf469e9feef255e229202d4b029e66e9fe
---

 libavcodec/crystalhd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index 9120940..137ed20 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -706,6 +706,15 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
 
     av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n");
 
+    /*
+     * The hardware doesn't return the first sample of a picture.
+     * Ignoring why it behaves this way, it's better to copy the sample from
+     * the second line, rather than the next sample across because the chroma
+     * values should be correct (assuming the decoded video was 4:2:0, which
+     * it was).
+     */
+    *((uint32_t *)src) = *((uint32_t *)(src + sStride));
+
     if (interlaced) {
         int dY = 0;
         int sY = 0;



More information about the ffmpeg-cvslog mailing list