From: Ronald B. <rb...@us...> - 2003-06-07 21:06:19
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: rbultje Date: Sat Jun 07 2003 14:06:18 PDT Log message: Loop through input capses instead of just picking the first, and handle encoding errors Modified files: ext/ffmpeg : gstffmpegenc.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegenc.c.diff?r1=1.19&r2=1.20 ====Begin Diffs==== Index: gstffmpegenc.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegenc.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- gstffmpegenc.c 7 Jun 2003 20:46:24 -0000 1.19 +++ gstffmpegenc.c 7 Jun 2003 21:06:05 -0000 1.20 @@ -284,11 +284,6 @@ ffmpegenc->context->qmax = 15; ffmpegenc->context->max_qdiff = 3; - /* fill in the context (width/height/pixfmt or - * rate/channels/samplefmt) */ - gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type, - caps, ffmpegenc->context); - /* no edges */ ffmpegenc->context->flags |= CODEC_FLAG_EMU_EDGE; @@ -298,11 +293,23 @@ ffmpegenc->context->frame_rate = 25 * DEFAULT_FRAME_RATE_BASE; ffmpegenc->context->frame_rate_base = DEFAULT_FRAME_RATE_BASE; - /* open codec */ - if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) { - GST_DEBUG (GST_CAT_PLUGIN_INFO, - "ffenc_%s: Failed to open FFMPEG codec", - oclass->in_plugin->name); + for (ret_caps = caps; ret_caps != NULL; ret_caps = ret_caps->next) { + /* fetch pix_fmt and so on */ + gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type, + caps, ffmpegenc->context); + + /* open codec */ + if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) { + GST_DEBUG (GST_CAT_PLUGIN_INFO, + "ffenc_%s: Failed to open FFMPEG codec", + oclass->in_plugin->name); + continue; + } + + break; + } + + if (ret_caps == NULL) { return GST_PAD_LINK_REFUSED; } @@ -373,6 +380,13 @@ default: g_assert(0); break; + } + + if (ret_size < 0) { + g_warning("ffenc_%s: failed to encode buffer", + oclass->in_plugin->name); + gst_buffer_unref (inbuf); + return; } /* bla */ |