Search
SailfishOS Open Build Service
>
Projects
>
home:sledge
:
branches:nemo:devel:hw:ti:omap4:common
>
gst-plugins-base
> 0023-ffmpegcolorspace-support-for-rowstride.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0023-ffmpegcolorspace-support-for-rowstride.patch of Package gst-plugins-base
From b1163248a601450e47d6172c3897ed0a5ee95821 Mon Sep 17 00:00:00 2001 From: Rob Clark <rob@ti.com> Date: Fri, 24 Dec 2010 20:55:43 -0600 Subject: [PATCH 23/38] ffmpegcolorspace: support for rowstride --- gst/ffmpegcolorspace/avcodec.h | 2 +- gst/ffmpegcolorspace/gstffmpegcodecmap.c | 75 +++++++++++++++++++-------- gst/ffmpegcolorspace/gstffmpegcodecmap.h | 1 + gst/ffmpegcolorspace/gstffmpegcolorspace.c | 30 +++++++++-- gst/ffmpegcolorspace/gstffmpegcolorspace.h | 1 + gst/ffmpegcolorspace/imgconvert.c | 12 ++-- 6 files changed, 86 insertions(+), 35 deletions(-) diff --git a/gst/ffmpegcolorspace/avcodec.h b/gst/ffmpegcolorspace/avcodec.h index 57f551c..a4928ee 100644 --- a/gst/ffmpegcolorspace/avcodec.h +++ b/gst/ffmpegcolorspace/avcodec.h @@ -217,7 +217,7 @@ typedef struct AVPaletteControl { } AVPaletteControl; -int avpicture_get_size(int pix_fmt, int width, int height); +int avpicture_get_size(int pix_fmt, int width, int height, int stride); void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift); const char *avcodec_get_pix_fmt_name(int pix_fmt); diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c index 318a90e..a277dc8 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c @@ -619,7 +619,8 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, if (!raw) return; - if (gst_structure_has_name (structure, "video/x-raw-yuv")) { + if (gst_structure_has_name (structure, "video/x-raw-yuv") || + gst_structure_has_name (structure, "video/x-raw-yuv-strided")) { guint32 fourcc; if (gst_structure_get_fourcc (structure, "format", &fourcc)) { @@ -828,10 +829,10 @@ gst_ffmpegcsp_caps_with_codectype (enum CodecType type, int gst_ffmpegcsp_avpicture_fill (AVPicture * picture, uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height, - int interlaced) + int stride, int interlaced) { int size, w2, h2, size2; - int stride, stride2; + int stride2; PixFmtInfo *pinfo; pinfo = get_pix_fmt_info (pix_fmt); @@ -847,11 +848,15 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, case PIX_FMT_YUVJ420P: case PIX_FMT_YUVJ422P: case PIX_FMT_YUVJ444P: - stride = GST_ROUND_UP_4 (width); h2 = ROUND_UP_X (height, pinfo->y_chroma_shift); - size = stride * h2; w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift); - stride2 = GST_ROUND_UP_4 (w2); + if (stride) { + stride2 = stride; + } else { + stride = GST_ROUND_UP_4 (width); + stride2 = GST_ROUND_UP_4 (w2); + } + size = stride * h2; h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift); size2 = stride2 * h2; picture->data[0] = ptr; @@ -882,11 +887,15 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return 2 * size + 2 * size2; case PIX_FMT_YVU410P: case PIX_FMT_YVU420P: - stride = GST_ROUND_UP_4 (width); h2 = ROUND_UP_X (height, pinfo->y_chroma_shift); - size = stride * h2; w2 = DIV_ROUND_UP_X (width, pinfo->x_chroma_shift); - stride2 = GST_ROUND_UP_4 (w2); + if (stride) { + stride2 = stride; + } else { + stride = GST_ROUND_UP_4 (width); + stride2 = GST_ROUND_UP_4 (w2); + } + size = stride * h2; h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift); size2 = stride2 * h2; picture->data[0] = ptr; @@ -898,11 +907,15 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return size + 2 * size2; case PIX_FMT_NV12: case PIX_FMT_NV21: - stride = GST_ROUND_UP_4 (width); h2 = ROUND_UP_X (height, pinfo->y_chroma_shift); - size = stride * h2; w2 = 2 * DIV_ROUND_UP_X (width, pinfo->x_chroma_shift); - stride2 = GST_ROUND_UP_4 (w2); + if (stride) { + stride2 = stride; + } else { + stride = GST_ROUND_UP_4 (width); + stride2 = GST_ROUND_UP_4 (w2); + } + size = stride * h2; h2 = DIV_ROUND_UP_X (height, pinfo->y_chroma_shift); size2 = stride2 * h2; picture->data[0] = ptr; @@ -914,7 +927,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return size + size2; case PIX_FMT_RGB24: case PIX_FMT_BGR24: - stride = GST_ROUND_UP_4 (width * 3); + if (!stride) { + stride = GST_ROUND_UP_4 (width * 3); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -930,7 +945,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, case PIX_FMT_ABGR32: case PIX_FMT_xRGB32: case PIX_FMT_BGRx32: - stride = width * 4; + if (!stride) { + stride = width * 4; + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -942,7 +959,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, case PIX_FMT_YUV422: case PIX_FMT_UYVY422: case PIX_FMT_YVYU422: - stride = GST_ROUND_UP_4 (width * 2); + if (!stride) { + stride = GST_ROUND_UP_4 (width * 2); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -950,7 +969,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, picture->linesize[0] = stride; return size; case PIX_FMT_V308: - stride = GST_ROUND_UP_4 (width * 3); + if (!stride) { + stride = GST_ROUND_UP_4 (width * 3); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -958,8 +979,10 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, picture->linesize[0] = stride; return size; case PIX_FMT_UYVY411: - stride = - GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) + GST_ROUND_UP_4 (width) / 2); + if (!stride) { + stride = GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) + + GST_ROUND_UP_4 (width) / 2); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -968,7 +991,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return size; case PIX_FMT_Y800: case PIX_FMT_GRAY8: - stride = GST_ROUND_UP_4 (width); + if (!stride) { + stride = GST_ROUND_UP_4 (width); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -978,7 +1003,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, case PIX_FMT_Y16: case PIX_FMT_GRAY16_L: case PIX_FMT_GRAY16_B: - stride = GST_ROUND_UP_4 (width * 2); + if (!stride) { + stride = GST_ROUND_UP_4 (width * 2); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -987,7 +1014,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return size; case PIX_FMT_MONOWHITE: case PIX_FMT_MONOBLACK: - stride = GST_ROUND_UP_4 ((width + 7) >> 3); + if (!stride) { + stride = GST_ROUND_UP_4 ((width + 7) >> 3); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; @@ -996,7 +1025,9 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, return size; case PIX_FMT_PAL8: /* already forced to be with stride, so same result as other function */ - stride = GST_ROUND_UP_4 (width); + if (!stride) { + stride = GST_ROUND_UP_4 (width); + } size = stride * height; picture->data[0] = ptr; picture->data[1] = ptr + size; /* palette is stored here as 256 32 bit words */ diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.h b/gst/ffmpegcolorspace/gstffmpegcodecmap.h index 077fe3f..3d08bb0 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.h +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.h @@ -52,6 +52,7 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, enum PixelFormat pix_fmt, int width, int height, + int stride, int interlaced); #endif /* __GST_FFMPEG_CODECMAP_H__ */ diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index 4ba0204..63430a0 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -48,6 +48,10 @@ GST_DEBUG_CATEGORY (ffmpegcolorspace_performance); "video/x-raw-yuv, width = "GST_VIDEO_SIZE_RANGE" , " \ "height="GST_VIDEO_SIZE_RANGE",framerate="GST_VIDEO_FPS_RANGE"," \ "format= (fourcc) { I420 , NV12 , NV21 , YV12 , YUY2 , Y42B , Y444 , YUV9 , YVU9 , Y41B , Y800 , Y8 , GREY , Y16 , UYVY , YVYU , IYU1 , v308 , AYUV, A420} ;" \ + "video/x-raw-yuv-strided, width = "GST_VIDEO_SIZE_RANGE" , " \ + "height="GST_VIDEO_SIZE_RANGE",framerate="GST_VIDEO_FPS_RANGE"," \ + "rowstride="GST_VIDEO_SIZE_RANGE"," \ + "format= (fourcc) { I420 , NV12 , NV21 , YV12 , YUY2 , Y42B , Y444 , YUV9 , YVU9 , Y41B , Y800 , Y8 , GREY , Y16 , UYVY , YVYU , IYU1 , v308 , AYUV, A420} ;" \ GST_VIDEO_CAPS_RGB";" \ GST_VIDEO_CAPS_BGR";" \ GST_VIDEO_CAPS_RGBx";" \ @@ -205,8 +209,8 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, { GstFFMpegCsp *space; GstStructure *structure; - gint in_height, in_width; - gint out_height, out_width; + gint in_height, in_width, in_stride = 0; + gint out_height, out_width, out_stride = 0; const GValue *in_framerate = NULL; const GValue *out_framerate = NULL; const GValue *in_par = NULL; @@ -225,6 +229,10 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, if (!res) goto no_width_height; + /* stride is optional: */ + if (gst_structure_has_name (structure, "video/x-raw-yuv-strided")) + gst_structure_get_int (structure, "rowstride", &in_stride); + /* and framerate */ in_framerate = gst_structure_get_value (structure, "framerate"); if (in_framerate == NULL || !GST_VALUE_HOLDS_FRACTION (in_framerate)) @@ -241,6 +249,10 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, if (!res) goto no_width_height; + /* stride is optional: */ + if (gst_structure_has_name (structure, "video/x-raw-yuv-strided")) + gst_structure_get_int (structure, "rowstride", &out_stride); + /* and framerate */ out_framerate = gst_structure_get_value (structure, "framerate"); if (out_framerate == NULL || !GST_VALUE_HOLDS_FRACTION (out_framerate)) @@ -263,6 +275,8 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, space->width = ctx->width = in_width; space->height = ctx->height = in_height; + space->in_stride = in_stride; + space->out_stride = out_stride; space->interlaced = FALSE; gst_structure_get_boolean (structure, "interlaced", &space->interlaced); @@ -401,7 +415,7 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, GstStructure *structure = NULL; AVCodecContext *ctx = NULL; gboolean ret = TRUE; - gint width, height; + gint width, height, stride = 0; g_assert (size); @@ -409,6 +423,10 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, gst_structure_get_int (structure, "width", &width); gst_structure_get_int (structure, "height", &height); + /* stride is optional: */ + if (gst_structure_has_name (structure, "video/x-raw-yuv-strided")) + gst_structure_get_int (structure, "rowstride", &stride); + ctx = avcodec_alloc_context (); g_assert (ctx != NULL); @@ -422,7 +440,7 @@ gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, goto beach; } - *size = avpicture_get_size (ctx->pix_fmt, width, height); + *size = avpicture_get_size (ctx->pix_fmt, width, height, stride); /* ffmpeg frames have the palette after the frame data, whereas * GStreamer currently puts it into the caps as 'palette_data' field, @@ -460,7 +478,7 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, /* fill from with source data */ gst_ffmpegcsp_avpicture_fill (&space->from_frame, GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height, - space->interlaced); + space->in_stride, space->interlaced); /* fill optional palette */ if (space->palette) @@ -469,7 +487,7 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, /* fill target frame */ gst_ffmpegcsp_avpicture_fill (&space->to_frame, GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height, - space->interlaced); + space->out_stride, space->interlaced); /* and convert */ result = img_convert (&space->to_frame, space->to_pixfmt, diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.h b/gst/ffmpegcolorspace/gstffmpegcolorspace.h index 198ab8a..bd5e01c 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.h +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.h @@ -46,6 +46,7 @@ struct _GstFFMpegCsp { GstVideoFilter element; gint width, height; + gint in_stride, out_stride; gboolean interlaced; gfloat fps; enum PixelFormat from_pixfmt, to_pixfmt; diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index cb145bb..414c4a0 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -594,12 +594,12 @@ avpicture_layout (const AVPicture * src, int pix_fmt, int width, int height, #endif int -avpicture_get_size (int pix_fmt, int width, int height) +avpicture_get_size (int pix_fmt, int width, int height, int stride) { AVPicture dummy_pict; return gst_ffmpegcsp_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, - height, FALSE); + height, stride, FALSE); } /** @@ -3518,16 +3518,16 @@ get_convert_table_entry (int src_pix_fmt, int dst_pix_fmt) static int avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height, - int interlaced) + int stride, int interlaced) { unsigned int size; void *ptr; - size = avpicture_get_size (pix_fmt, width, height); + size = avpicture_get_size (pix_fmt, width, height, stride); ptr = av_malloc (size); if (!ptr) goto fail; - gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height, + gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height, stride, interlaced); return 0; fail: @@ -3775,7 +3775,7 @@ no_chroma_filter: else int_pix_fmt = PIX_FMT_RGB24; } - if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height, + if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height, 0, dst->interlaced) < 0) return -1; ret = -1; -- 1.7.5.4