ext/ffmpeg/: respect pixel-aspect-ratio when encoding.
authorThomas Vander Stichele <thomas@apestaart.org>
Sun, 12 Feb 2006 19:54:16 +0000 (19:54 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Sun, 12 Feb 2006 19:54:16 +0000 (19:54 +0000)
Original commit message from CVS:

* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_to_pixfmt):
* ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps):
respect pixel-aspect-ratio when encoding.

ChangeLog
ext/ffmpeg/gstffmpegcodecmap.c
ext/ffmpeg/gstffmpegenc.c

index 3b21a0e2097cf1a5dcde5b39f947051213997f88..477343107fd2b8de2befae50554a8f28f6ed75f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-12  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_to_pixfmt):
+       * ext/ffmpeg/gstffmpegenc.c: (gst_ffmpegenc_getcaps):
+         respect pixel-aspect-ratio when encoding.
+
 2006-02-12  Edward Hervey  <edward@fluendo.com>
 
        * ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_init),
index 947f5e917991f52f9f94df0c128fe02edc9384b7..c98cafb586abcbf0c420dcad584c1c44e83f384c 100644 (file)
@@ -1141,7 +1141,9 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
 {
   GstStructure *structure;
   const GValue *fps;
+  const GValue *par;
 
+  GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps);
   g_return_if_fail (gst_caps_get_size (caps) == 1);
   structure = gst_caps_get_structure (caps, 0);
 
@@ -1157,14 +1159,26 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
     context->time_base.num = gst_value_get_fraction_denominator (fps);
 
     GST_DEBUG ("setting framerate %d/%d = %lf",
-            context->time_base.den, context->time_base.num, 
+            context->time_base.den, context->time_base.num,
             1. * context->time_base.den / context->time_base.num);
   }
 
+  par = gst_structure_get_value (structure, "pixel-aspect-ratio");
+  if (par != NULL && GST_VALUE_HOLDS_FRACTION (par)) {
+
+    context->sample_aspect_ratio.num = gst_value_get_fraction_numerator (par);
+    context->sample_aspect_ratio.den = gst_value_get_fraction_denominator (par);
+
+    GST_DEBUG ("setting pixel-aspect-ratio %d/%d = %lf",
+            context->sample_aspect_ratio.den, context->sample_aspect_ratio.num,
+            1. * context->sample_aspect_ratio.den / context->sample_aspect_ratio.num);
+  }
+
   if (!raw)
     return;
 
-  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)); 
+  g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
+  g_return_if_fail (par != NULL && GST_VALUE_HOLDS_FRACTION (par));
 
   if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
     guint32 fourcc;
index 6306a4fa4b061ab721340bacec0901ca45954d7e..cf952c182d2b3ae205305d6d94bffcd4619b0733 100644 (file)
@@ -39,6 +39,9 @@
 #define DEFAULT_VIDEO_GOP_SIZE 15
 #define DEFAULT_AUDIO_BITRATE 128000
 
+#define DEFAULT_WIDTH 352
+#define DEFAULT_HEIGHT 288
+
 typedef struct _GstFFMpegEnc GstFFMpegEnc;
 
 struct _GstFFMpegEnc
@@ -325,11 +328,11 @@ gst_ffmpegenc_getcaps (GstPad * pad)
   }
 
   /* set some default properties */
-  ctx->width = 352;
-  ctx->height = 288;
+  ctx->width = DEFAULT_WIDTH;
+  ctx->height = DEFAULT_HEIGHT;
   ctx->time_base.num = DEFAULT_FRAME_RATE_BASE;
   ctx->time_base.den = 25 * DEFAULT_FRAME_RATE_BASE;
-  ctx->bit_rate = 350 * 1000;
+  ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
   /* makes it silent */
   ctx->strict_std_compliance = -1;