[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    [gst-cvs] gst-ffmpeg: gstffmpegenc: Try getting the caps for the
From:       bilboed () kemper ! freedesktop ! org (Edward Hervey)
Date:       2009-07-31 11:27:21
Message-ID: 20090731112721.3A78E10051 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-ffmpeg
Branch: master
Commit: 56887682d058c40b911bdd57cc8c59aabd5cb79b
URL:    http://cgit.freedesktop.org/gstreamer/gst-ffmpeg/commit/?id=56887682d058c40b911bdd57cc8c59aabd5cb79b


Author: Edward Hervey <bilboed@bilboed.com>
Date:   Fri Jul 31 13:27:28 2009 +0200

gstffmpegenc: Try getting the caps for the declared pixfmt without a context.

PixFmt that are declared in AVCodec.pix_fmts are ones which are 'officially'
declared as being supported. We should therefore not have to create a
AVCodecContext and open an encoder to know if it's supported or not.
Also, doing it this way allows us to better pickup configuration overrides
we have in gstffmpegcodecmap for some codecs (like restrictions on width,
height, framerate like it's the case for dnxhd).

Fixes #575545

---

 ext/ffmpeg/gstffmpegenc.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c
index 538fbe6..1a67db0 100644
--- a/ext/ffmpeg/gstffmpegenc.c
+++ b/ext/ffmpeg/gstffmpegenc.c
@@ -334,11 +334,32 @@ gst_ffmpegenc_getcaps (GstPad * pad)
     /* override looping all pixfmt if codec declares pixfmts;
      * these may not properly check and report supported pixfmt during _init */
     if (oclass->in_plugin->pix_fmts) {
-      if ((pixfmt = oclass->in_plugin->pix_fmts[i++]) == PIX_FMT_NONE)
+      if ((pixfmt = oclass->in_plugin->pix_fmts[i++]) == PIX_FMT_NONE) {
+        GST_DEBUG_OBJECT (ffmpegenc,
+            "At the end of official pixfmt for this codec, breaking out");
         break;
+      }
+      GST_DEBUG_OBJECT (ffmpegenc,
+          "Got an official pixfmt [%d], attempting to get caps", pixfmt);
+      tmpcaps =
+          gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type, NULL,
+          oclass->in_plugin->id, TRUE);
+      if (tmpcaps) {
+        GST_DEBUG_OBJECT (ffmpegenc, "Got caps, breaking out");
+        if (!caps)
+          caps = gst_caps_new_empty ();
+        gst_caps_append (caps, tmpcaps);
+        break;
+      }
+      GST_DEBUG_OBJECT (ffmpegenc,
+          "Couldn't figure out caps without context, trying again with a context");
     }
-    if (pixfmt >= PIX_FMT_NB)
+
+    GST_DEBUG_OBJECT (ffmpegenc, "pixfmt :%d", pixfmt);
+    if (pixfmt >= PIX_FMT_NB) {
+      GST_WARNING ("Invalid pixfmt, breaking out");
       break;
+    }
 
     /* need to start with a fresh codec_context each time around, since
      * codec_close may have released stuff causing the next pass to segfault */
@@ -359,6 +380,8 @@ gst_ffmpegenc_getcaps (GstPad * pad)
     ctx->strict_std_compliance = -1;
 
     ctx->pix_fmt = pixfmt;
+
+    GST_DEBUG ("Attempting to open codec");
     if (gst_ffmpeg_avcodec_open (ctx, oclass->in_plugin) >= 0 &&
         ctx->pix_fmt == pixfmt) {
       ctx->width = -1;
@@ -373,6 +396,9 @@ gst_ffmpegenc_getcaps (GstPad * pad)
             "Couldn't get caps for oclass->in_plugin->name:%s",
             oclass->in_plugin->name);
       gst_ffmpeg_avcodec_close (ctx);
+    } else {
+      GST_DEBUG_OBJECT (ffmpegenc, "Opening codec failed with pixfmt : %d",
+          pixfmt);
     }
     if (ctx->priv_data)
       gst_ffmpeg_avcodec_close (ctx);


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
gstreamer-cvs mailing list
gstreamer-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic