diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c index 44b7bcd471..2fa64fa6b6 100644 --- a/gst-libs/gst/video/video-converter.c +++ b/gst-libs/gst/video/video-converter.c @@ -566,28 +566,19 @@ get_opt_enum (GstVideoConverter * convert, const gchar * opt, GType type, return res; } -static const gchar * -get_opt_str (GstVideoConverter * convert, const gchar * opt, const gchar * def) -{ - const gchar *res; - if (!(res = gst_structure_get_string (convert->config, opt))) - res = def; - return res; -} - #define DEFAULT_OPT_FILL_BORDER TRUE #define DEFAULT_OPT_ALPHA_VALUE 1.0 /* options copy, set, mult */ -#define DEFAULT_OPT_ALPHA_MODE "copy" +#define DEFAULT_OPT_ALPHA_MODE GST_VIDEO_ALPHA_MODE_COPY #define DEFAULT_OPT_BORDER_ARGB 0xff000000 /* options full, input-only, output-only, none */ -#define DEFAULT_OPT_MATRIX_MODE "full" +#define DEFAULT_OPT_MATRIX_MODE GST_VIDEO_MATRIX_MODE_FULL /* none, remap */ -#define DEFAULT_OPT_GAMMA_MODE "none" +#define DEFAULT_OPT_GAMMA_MODE GST_VIDEO_GAMMA_MODE_NONE /* none, merge-only, fast */ -#define DEFAULT_OPT_PRIMARIES_MODE "none" +#define DEFAULT_OPT_PRIMARIES_MODE GST_VIDEO_PRIMARIES_MODE_NONE /* options full, upsample-only, downsample-only, none */ -#define DEFAULT_OPT_CHROMA_MODE "full" +#define DEFAULT_OPT_CHROMA_MODE GST_VIDEO_CHROMA_MODE_FULL #define DEFAULT_OPT_RESAMPLER_METHOD GST_VIDEO_RESAMPLER_METHOD_CUBIC #define DEFAULT_OPT_CHROMA_RESAMPLER_METHOD GST_VIDEO_RESAMPLER_METHOD_LINEAR #define DEFAULT_OPT_RESAMPLER_TAPS 0 @@ -598,18 +589,18 @@ get_opt_str (GstVideoConverter * convert, const gchar * opt, const gchar * def) GST_VIDEO_CONVERTER_OPT_FILL_BORDER, DEFAULT_OPT_FILL_BORDER) #define GET_OPT_ALPHA_VALUE(c) get_opt_double(c, \ GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE, DEFAULT_OPT_ALPHA_VALUE) -#define GET_OPT_ALPHA_MODE(c) get_opt_str(c, \ - GST_VIDEO_CONVERTER_OPT_ALPHA_MODE, DEFAULT_OPT_ALPHA_MODE) +#define GET_OPT_ALPHA_MODE(c) get_opt_enum(c, \ + GST_VIDEO_CONVERTER_OPT_ALPHA_MODE, GST_TYPE_VIDEO_ALPHA_MODE, DEFAULT_OPT_ALPHA_MODE) #define GET_OPT_BORDER_ARGB(c) get_opt_uint(c, \ GST_VIDEO_CONVERTER_OPT_BORDER_ARGB, DEFAULT_OPT_BORDER_ARGB) -#define GET_OPT_MATRIX_MODE(c) get_opt_str(c, \ - GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, DEFAULT_OPT_MATRIX_MODE) -#define GET_OPT_GAMMA_MODE(c) get_opt_str(c, \ - GST_VIDEO_CONVERTER_OPT_GAMMA_MODE, DEFAULT_OPT_GAMMA_MODE) -#define GET_OPT_PRIMARIES_MODE(c) get_opt_str(c, \ - GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE, DEFAULT_OPT_PRIMARIES_MODE) -#define GET_OPT_CHROMA_MODE(c) get_opt_str(c, \ - GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, DEFAULT_OPT_CHROMA_MODE) +#define GET_OPT_MATRIX_MODE(c) get_opt_enum(c, \ + GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, GST_TYPE_VIDEO_MATRIX_MODE, DEFAULT_OPT_MATRIX_MODE) +#define GET_OPT_GAMMA_MODE(c) get_opt_enum(c, \ + GST_VIDEO_CONVERTER_OPT_GAMMA_MODE, GST_TYPE_VIDEO_GAMMA_MODE, DEFAULT_OPT_GAMMA_MODE) +#define GET_OPT_PRIMARIES_MODE(c) get_opt_enum(c, \ + GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE, GST_TYPE_VIDEO_PRIMARIES_MODE, DEFAULT_OPT_PRIMARIES_MODE) +#define GET_OPT_CHROMA_MODE(c) get_opt_enum(c, \ + GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, GST_TYPE_VIDEO_CHROMA_MODE, DEFAULT_OPT_CHROMA_MODE) #define GET_OPT_RESAMPLER_METHOD(c) get_opt_enum(c, \ GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD, GST_TYPE_VIDEO_RESAMPLER_METHOD, \ DEFAULT_OPT_RESAMPLER_METHOD) @@ -624,26 +615,26 @@ get_opt_str (GstVideoConverter * convert, const gchar * opt, const gchar * def) #define GET_OPT_DITHER_QUANTIZATION(c) get_opt_uint(c, \ GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION, DEFAULT_OPT_DITHER_QUANTIZATION) -#define CHECK_ALPHA_COPY(c) (!g_strcmp0(GET_OPT_ALPHA_MODE(c), "copy")) -#define CHECK_ALPHA_SET(c) (!g_strcmp0(GET_OPT_ALPHA_MODE(c), "set")) -#define CHECK_ALPHA_MULT(c) (!g_strcmp0(GET_OPT_ALPHA_MODE(c), "mult")) +#define CHECK_ALPHA_COPY(c) (GET_OPT_ALPHA_MODE(c) == GST_VIDEO_ALPHA_MODE_COPY) +#define CHECK_ALPHA_SET(c) (GET_OPT_ALPHA_MODE(c) == GST_VIDEO_ALPHA_MODE_SET) +#define CHECK_ALPHA_MULT(c) (GET_OPT_ALPHA_MODE(c) == GST_VIDEO_ALPHA_MODE_MULT) -#define CHECK_MATRIX_FULL(c) (!g_strcmp0(GET_OPT_MATRIX_MODE(c), "full")) -#define CHECK_MATRIX_INPUT(c) (!g_strcmp0(GET_OPT_MATRIX_MODE(c), "input-only")) -#define CHECK_MATRIX_OUTPUT(c) (!g_strcmp0(GET_OPT_MATRIX_MODE(c), "output-only")) -#define CHECK_MATRIX_NONE(c) (!g_strcmp0(GET_OPT_MATRIX_MODE(c), "none")) +#define CHECK_MATRIX_FULL(c) (GET_OPT_MATRIX_MODE(c) == GST_VIDEO_MATRIX_MODE_FULL) +#define CHECK_MATRIX_INPUT(c) (GET_OPT_MATRIX_MODE(c) == GST_VIDEO_MATRIX_MODE_INPUT_ONLY) +#define CHECK_MATRIX_OUTPUT(c) (GET_OPT_MATRIX_MODE(c) == GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY) +#define CHECK_MATRIX_NONE(c) (GET_OPT_MATRIX_MODE(c) == GST_VIDEO_MATRIX_MODE_NONE) -#define CHECK_GAMMA_NONE(c) (!g_strcmp0(GET_OPT_GAMMA_MODE(c), "none")) -#define CHECK_GAMMA_REMAP(c) (!g_strcmp0(GET_OPT_GAMMA_MODE(c), "remap")) +#define CHECK_GAMMA_NONE(c) (GET_OPT_GAMMA_MODE(c) == GST_VIDEO_GAMMA_MODE_NONE) +#define CHECK_GAMMA_REMAP(c) (GET_OPT_GAMMA_MODE(c) == GST_VIDEO_GAMMA_MODE_REMAP) -#define CHECK_PRIMARIES_NONE(c) (!g_strcmp0(GET_OPT_PRIMARIES_MODE(c), "none")) -#define CHECK_PRIMARIES_MERGE(c) (!g_strcmp0(GET_OPT_PRIMARIES_MODE(c), "merge-only")) -#define CHECK_PRIMARIES_FAST(c) (!g_strcmp0(GET_OPT_PRIMARIES_MODE(c), "fast")) +#define CHECK_PRIMARIES_NONE(c) (GET_OPT_PRIMARIES_MODE(c) == GST_VIDEO_PRIMARIES_MODE_NONE) +#define CHECK_PRIMARIES_MERGE(c) (GET_OPT_PRIMARIES_MODE(c) == GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY) +#define CHECK_PRIMARIES_FAST(c) (GET_OPT_PRIMARIES_MODE(c) == GST_VIDEO_PRIMARIES_MODE_FAST) -#define CHECK_CHROMA_FULL(c) (!g_strcmp0(GET_OPT_CHROMA_MODE(c), "full")) -#define CHECK_CHROMA_UPSAMPLE(c) (!g_strcmp0(GET_OPT_CHROMA_MODE(c), "upsample-only")) -#define CHECK_CHROMA_DOWNSAMPLE(c) (!g_strcmp0(GET_OPT_CHROMA_MODE(c), "downsample-only")) -#define CHECK_CHROMA_NONE(c) (!g_strcmp0(GET_OPT_CHROMA_MODE(c), "none")) +#define CHECK_CHROMA_FULL(c) (GET_OPT_CHROMA_MODE(c) == GST_VIDEO_CHROMA_MODE_FULL) +#define CHECK_CHROMA_UPSAMPLE(c) (GET_OPT_CHROMA_MODE(c) == GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY) +#define CHECK_CHROMA_DOWNSAMPLE(c) (GET_OPT_CHROMA_MODE(c) == GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY) +#define CHECK_CHROMA_NONE(c) (GET_OPT_CHROMA_MODE(c) == GST_VIDEO_CHROMA_MODE_NONE) static GstLineCache * chain_unpack_line (GstVideoConverter * convert) diff --git a/gst-libs/gst/video/video-converter.h b/gst-libs/gst/video/video-converter.h index e69d4c06b8..c9477c89da 100644 --- a/gst-libs/gst/video/video-converter.h +++ b/gst-libs/gst/video/video-converter.h @@ -132,21 +132,32 @@ G_BEGIN_DECLS * Default to 1.0 */ #define GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE "GstVideoConverter.alpha-value" +/** + * GstVideoAlphaMode: + * @GST_VIDEO_ALPHA_MODE_COPY: When input and output have alpha, it will be copied. + * When the input has no alpha, alpha will be set to + * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE + * @GST_VIDEO_ALPHA_MODE_SET: set all alpha to + * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE + * @GST_VIDEO_ALPHA_MODE_MULT: multiply all alpha with + * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE. + * When the input format has no alpha but the output format has, the + * alpha value will be set to #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE + * + * Different alpha modes. + * + * Since: 1.6 + */ +typedef enum { + GST_VIDEO_ALPHA_MODE_COPY, + GST_VIDEO_ALPHA_MODE_SET, + GST_VIDEO_ALPHA_MODE_MULT +} GstVideoAlphaMode; /** * GST_VIDEO_CONVERTER_OPT_ALPHA_MODE: * - * #G_TYPE_STRING, the alpha mode to use. - * - * "copy": When input and output have alpha, it will be copied. - * When the input has no alpha, alpha will be set to - * GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE - * "set": set all alpha to #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE - * "mult": multiply all alpha with #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE. - * When the input format has no alpha but the output format has, - * the alpha value will be set to - * #GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE - * - * Default to "none". + * #GST_TYPE_VIDEO_ALPHA_MODE, the alpha mode to use. + * Default is #GST_VIDEO_ALPHA_MODE_COPY. */ #define GST_VIDEO_CONVERTER_OPT_ALPHA_MODE "GstVideoConverter.alpha-mode" /** @@ -157,55 +168,100 @@ G_BEGIN_DECLS * Default 0xff000000 */ #define GST_VIDEO_CONVERTER_OPT_BORDER_ARGB "GstVideoConverter.border-argb" + +/** + * GstVideoChromaMode: + * @GST_VIDEO_CHROMA_MODE_FULL: do full chroma up and down sampling + * @GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY: only perform chroma upsampling + * @GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY: only perform chroma downsampling + * @GST_VIDEO_CHROMA_MODE_NONE: disable chroma resampling + * + * Different chroma downsampling and upsampling modes + * + * Since: 1.6 + */ +typedef enum { + GST_VIDEO_CHROMA_MODE_FULL, + GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY, + GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY, + GST_VIDEO_CHROMA_MODE_NONE +} GstVideoChromaMode; + /** * GST_VIDEO_CONVERTER_OPT_CHROMA_MODE: * - * #G_TYPE_STRING, set the chroma resample mode subsampled formats. - * - * "full": do full chroma up and down sampling - * "upsample-only": only perform chroma upsampling - * "downsample-only": only perform chroma downsampling - * "none": disable chroma resampling - * - * Default "full" + * #GST_TYPE_VIDEO_CHROMA_MODE, set the chroma resample mode subsampled + * formats. Default is #GST_VIDEO_CHROMA_MODE_FULL. */ #define GST_VIDEO_CONVERTER_OPT_CHROMA_MODE "GstVideoConverter.chroma-mode" + +/** + *GstVideoMatrixMode: + * @GST_VIDEO_MATRIX_MODE_FULL: do conversion between color matrices + * @GST_VIDEO_MATRIX_MODE_INPUT_ONLY: use the input color matrix to convert + * to and from R'G'B + * @GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY: use the output color matrix to convert + * to and from R'G'B + * @GST_VIDEO_MATRIX_MODE_NONE: disable color matrix conversion. + * + * Different color matrix conversion modes + * + * Since: 1.6 + */ +typedef enum { + GST_VIDEO_MATRIX_MODE_FULL, + GST_VIDEO_MATRIX_MODE_INPUT_ONLY, + GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY, + GST_VIDEO_MATRIX_MODE_NONE +} GstVideoMatrixMode; /** * GST_VIDEO_CONVERTER_OPT_MATRIX_MODE: * - * #G_TYPE_STRING, set the color matrix conversion mode for converting - * between Y'PbPr and non-linear RGB (R'G'B'). - * - * "full": do conversion between color matrices - * "input-only": use the input color matrix to convert to and from R'G'B - * "output-only": use the output color matrix to convert to and from R'G'B - * "none": disable color matrix conversion. - * - * Default "full" + * #GST_TYPE_VIDEO_MATRIX_MODE, set the color matrix conversion mode for + * converting between Y'PbPr and non-linear RGB (R'G'B'). + * Default is #GST_VIDEO_MATRIX_MODE_FULL. */ #define GST_VIDEO_CONVERTER_OPT_MATRIX_MODE "GstVideoConverter.matrix-mode" +/** + * GstVideoGammaMode: + * @GST_VIDEO_GAMMA_MODE_NONE: disable gamma handling + * @GST_VIDEO_GAMMA_MODE_REMAP: convert between input and output gamma + * Different gamma conversion modes + * + * Since: 1.6 + */ +typedef enum { + GST_VIDEO_GAMMA_MODE_NONE, + GST_VIDEO_GAMMA_MODE_REMAP +} GstVideoGammaMode; /** * GST_VIDEO_CONVERTER_OPT_GAMMA_MODE: * - * #G_TYPE_STRING, set the gamma mode. - * - * "none": disable gamma handling - * "remap": convert between input and output gamma - * - * Default "none" + * #GST_TYPE_VIDEO_GAMMA_MODE, set the gamma mode. + * Default is #GST_VIDEO_GAMMA_MODE_NONE. */ #define GST_VIDEO_CONVERTER_OPT_GAMMA_MODE "GstVideoConverter.gamma-mode" +/** + * GstVideoPrimariesMode: + * @GST_VIDEO_PRIMARIES_MODE_NONE: disable conversion between primaries + * @GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY: do conversion between primaries only + * when it can be merged with color matrix conversion. + * @GST_VIDEO_PRIMARIES_MODE_FAST: fast conversion between primaries + * + * Different primaries conversion modes + * + * Since: 1.6 + */ +typedef enum { + GST_VIDEO_PRIMARIES_MODE_NONE, + GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY, + GST_VIDEO_PRIMARIES_MODE_FAST +} GstVideoPrimariesMode; /** * GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE: * - * #G_TYPE_STRING, set the primaries conversion mode. - * - * "none": disable conversion between primaries - * "merge-only": do conversion between primaries only when it can be merged - * with color matrix conversion. - * "fast": fast conversion between primaries - * - * Default "none" + * #GST_TYPE_VIDEO_PRIMARIES_MODE, set the primaries conversion mode. + * Default is #GST_VIDEO_PRIMARIES_MODE_NONE. */ #define GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE "GstVideoConverter.primaries-mode" diff --git a/gst-libs/gst/video/video-resampler.h b/gst-libs/gst/video/video-resampler.h index d0c18cc1bf..699f38294d 100644 --- a/gst-libs/gst/video/video-resampler.h +++ b/gst-libs/gst/video/video-resampler.h @@ -45,7 +45,7 @@ typedef enum { GST_VIDEO_RESAMPLER_METHOD_LINEAR, GST_VIDEO_RESAMPLER_METHOD_CUBIC, GST_VIDEO_RESAMPLER_METHOD_SINC, - GST_VIDEO_RESAMPLER_METHOD_LANCZOS, + GST_VIDEO_RESAMPLER_METHOD_LANCZOS } GstVideoResamplerMethod; /** diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index 20eb6e9f76..b694ea37e5 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -603,10 +603,11 @@ gst_video_scale_set_info (GstVideoFilter * filter, GstCaps * in, out_info->width - videoscale->borders_w, GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT, G_TYPE_INT, out_info->height - videoscale->borders_h, - GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, G_TYPE_STRING, "none", - GST_VIDEO_CONVERTER_OPT_DITHER_METHOD, GST_TYPE_VIDEO_DITHER_METHOD, - GST_VIDEO_DITHER_NONE, GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, - G_TYPE_STRING, "none", NULL); + GST_VIDEO_CONVERTER_OPT_MATRIX_MODE, GST_TYPE_VIDEO_MATRIX_MODE, + GST_VIDEO_MATRIX_MODE_NONE, GST_VIDEO_CONVERTER_OPT_DITHER_METHOD, + GST_TYPE_VIDEO_DITHER_METHOD, GST_VIDEO_DITHER_NONE, + GST_VIDEO_CONVERTER_OPT_CHROMA_MODE, GST_TYPE_VIDEO_CHROMA_MODE, + GST_VIDEO_CHROMA_MODE_NONE, NULL); if (videoscale->gamma_decode) { gst_structure_set (options,