+/* for grayscale with alpha */
+static void
+fill_frame_packed8_2 (GstVideoFrame * frame, opj_image_t * image)
+{
+ gint x, y, w, h, c;
+ guint8 *data_out, *tmp;
+ const gint *data_in[2];
+ gint dstride;
+ gint off[2];
+
+ w = GST_VIDEO_FRAME_WIDTH (frame);
+ h = GST_VIDEO_FRAME_HEIGHT (frame);
+ data_out = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+ dstride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
+
+ for (c = 0; c < 2; c++) {
+ data_in[c] = image->comps[c].data;
+ off[c] = 0x80 * image->comps[c].sgnd;
+ };
+
+ for (y = 0; y < h; y++) {
+ tmp = data_out;
+
+ for (x = 0; x < w; x++) {
+ /* alpha, from 2nd input channel */
+ tmp[0] = off[1] + *data_in[1];
+ /* luminance, from first input channel */
+ tmp[1] = off[0] + *data_in[0];
+ tmp[2] = tmp[1];
+ tmp[3] = tmp[1];
+ data_in[0]++;
+ data_in[1]++;
+ tmp += 4;
+ }
+ data_out += dstride;
+ }
+}
+
+/* for grayscale with alpha */
+static void
+fill_frame_packed16_2 (GstVideoFrame * frame, opj_image_t * image)
+{
+ gint x, y, w, h, c;
+ guint16 *data_out, *tmp;
+ const gint *data_in[2];
+ gint dstride;
+ gint shift[2], off[2];
+
+ w = GST_VIDEO_FRAME_WIDTH (frame);
+ h = GST_VIDEO_FRAME_HEIGHT (frame);
+ data_out = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
+ dstride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0) / 2;
+
+ for (c = 0; c < 2; c++) {
+ data_in[c] = image->comps[c].data;
+ off[c] = (1 << (image->comps[c].prec - 1)) * image->comps[c].sgnd;
+ shift[c] =
+ MAX (MIN (GST_VIDEO_FRAME_COMP_DEPTH (frame, c) - image->comps[c].prec,
+ 8), 0);
+ }
+
+ for (y = 0; y < h; y++) {
+ tmp = data_out;
+
+ for (x = 0; x < w; x++) {
+ /* alpha, from 2nd input channel */
+ tmp[0] = off[1] + (*data_in[1] << shift[1]);
+ /* luminance, from first input channel */
+ tmp[1] = off[0] + (*data_in[0] << shift[0]);
+ tmp[2] = tmp[1];
+ tmp[3] = tmp[1];
+ tmp += 4;
+ data_in[0]++;
+ data_in[1]++;
+ }
+ data_out += dstride;
+ }
+}
+
+