equal
deleted
inserted
replaced
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * SECTION:element-ffmpegcolorspace |
23 * SECTION:element-ffmpegcolorspace |
24 * |
24 * |
25 * Convert video frames between a great variety of colorspace formats. |
|
26 * |
|
27 * <refsect2> |
25 * <refsect2> |
28 * <title>Example launch line</title> |
26 * <title>Example launch line</title> |
29 * |[ |
27 * <para> |
|
28 * <programlisting> |
30 * gst-launch -v videotestsrc ! video/x-raw-yuv,format=\(fourcc\)YUY2 ! ffmpegcolorspace ! ximagesink |
29 * gst-launch -v videotestsrc ! video/x-raw-yuv,format=\(fourcc\)YUY2 ! ffmpegcolorspace ! ximagesink |
31 * ]| |
30 * </programlisting> |
|
31 * </para> |
32 * </refsect2> |
32 * </refsect2> |
33 */ |
33 */ |
34 |
34 |
35 #ifdef HAVE_CONFIG_H |
35 #ifdef HAVE_CONFIG_H |
36 # include "config.h" |
36 # include "config.h" |
137 * put it first in the list. */ |
137 * put it first in the list. */ |
138 static GstCaps * |
138 static GstCaps * |
139 gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans, |
139 gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans, |
140 GstPadDirection direction, GstCaps * caps) |
140 GstPadDirection direction, GstCaps * caps) |
141 { |
141 { |
|
142 GstFFMpegCsp *space; |
142 GstCaps *template; |
143 GstCaps *template; |
143 GstCaps *result; |
144 GstCaps *result; |
|
145 |
|
146 space = GST_FFMPEGCSP (btrans); |
144 |
147 |
145 template = gst_ffmpegcsp_codectype_to_caps (CODEC_TYPE_VIDEO, NULL); |
148 template = gst_ffmpegcsp_codectype_to_caps (CODEC_TYPE_VIDEO, NULL); |
146 result = gst_caps_intersect (caps, template); |
149 result = gst_caps_intersect (caps, template); |
147 gst_caps_unref (template); |
150 gst_caps_unref (template); |
148 |
151 |
374 |
377 |
375 static gboolean |
378 static gboolean |
376 gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, |
379 gst_ffmpegcsp_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, |
377 guint * size) |
380 guint * size) |
378 { |
381 { |
|
382 GstFFMpegCsp *space = NULL; |
379 GstStructure *structure = NULL; |
383 GstStructure *structure = NULL; |
380 AVCodecContext *ctx = NULL; |
384 AVCodecContext *ctx = NULL; |
381 gboolean ret = TRUE; |
385 gboolean ret = TRUE; |
382 gint width, height; |
386 gint width, height; |
383 |
387 |
384 g_assert (size); |
388 g_assert (size); |
385 |
389 |
|
390 space = GST_FFMPEGCSP (btrans); |
|
391 |
386 structure = gst_caps_get_structure (caps, 0); |
392 structure = gst_caps_get_structure (caps, 0); |
387 gst_structure_get_int (structure, "width", &width); |
393 gst_structure_get_int (structure, "width", &width); |
388 gst_structure_get_int (structure, "height", &height); |
394 gst_structure_get_int (structure, "height", &height); |
389 |
395 |
390 ctx = avcodec_alloc_context (); |
396 ctx = avcodec_alloc_context (); |
404 |
410 |
405 /* ffmpeg frames have the palette after the frame data, whereas |
411 /* ffmpeg frames have the palette after the frame data, whereas |
406 * GStreamer currently puts it into the caps as 'palette_data' field, |
412 * GStreamer currently puts it into the caps as 'palette_data' field, |
407 * so for paletted data the frame size avpicture_get_size() returns is |
413 * so for paletted data the frame size avpicture_get_size() returns is |
408 * 1024 bytes larger than what GStreamer expects. */ |
414 * 1024 bytes larger than what GStreamer expects. */ |
409 if (gst_structure_has_field (structure, "palette_data") && |
415 if (gst_structure_has_field (structure, "palette_data")) { |
410 ctx->pix_fmt == PIX_FMT_PAL8) { |
|
411 *size -= 4 * 256; /* = AVPALETTE_SIZE */ |
416 *size -= 4 * 256; /* = AVPALETTE_SIZE */ |
412 } |
417 } |
413 |
418 |
414 beach: |
419 beach: |
415 |
420 |