aomenc: Handle 8 bit_depth images with AOM_IMG_FMT_HIGHBITDEPTH enabled
authorSean-Der <sean@siobud.com>
Wed, 27 Jun 2018 09:48:00 +0000 (09:48 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 29 Jun 2018 05:47:59 +0000 (07:47 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=791674

ext/aom/gstav1dec.c

index 23b18f4..6e0a9bd 100644 (file)
@@ -285,7 +285,7 @@ static void
 gst_av1_dec_image_to_buffer (GstAV1Dec * dec, const aom_image_t * img,
     GstBuffer * buffer)
 {
-  int deststride, srcstride, height, width, line, comp;
+  int deststride, srcstride, height, width, line, comp, y;
   guint8 *dest, *src;
   GstVideoFrame frame;
   GstVideoInfo *info = &dec->output_state->info;
@@ -298,13 +298,25 @@ gst_av1_dec_image_to_buffer (GstAV1Dec * dec, const aom_image_t * img,
   for (comp = 0; comp < 3; comp++) {
     dest = GST_VIDEO_FRAME_COMP_DATA (&frame, comp);
     src = img->planes[comp];
-    width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, comp)
-        * GST_VIDEO_FRAME_COMP_PSTRIDE (&frame, comp);
+    width =
+        GST_VIDEO_FRAME_COMP_WIDTH (&frame,
+        comp) * GST_VIDEO_FRAME_COMP_PSTRIDE (&frame, comp);
     height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, comp);
     deststride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, comp);
     srcstride = img->stride[comp];
 
-    if (srcstride == deststride) {
+    if ((img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) && img->bit_depth == 8) {
+      GST_TRACE_OBJECT (dec,
+          "HIGHBITDEPTH image with 8 bit_depth. Comp %d: %d != %d, copying "
+          "line by line.", comp, srcstride, deststride);
+      for (line = 0; line < height; line++) {
+        for (y = 0; y < width; y++) {
+          dest[y] = src[y * 2];
+        }
+        dest += deststride;
+        src += srcstride;
+      }
+    } else if (srcstride == deststride) {
       GST_TRACE_OBJECT (dec, "Stride matches. Comp %d: %d, copying full plane",
           comp, srcstride);
       memcpy (dest, src, srcstride * height);