GNOME Bugzilla – Bug 496127
[deinterlace/scale/postproc] support for non-I420 colorspaces
Last modified: 2008-05-06 14:31:48 UTC
Right now, both ffdeinterlace and postproc_ffmpegdeint only handle 4:2:0 input. If input is 4:2:2, the only option is to convert colorspace before. However, there is no interlacing information carried within the current Gstreamer, so the 4:2:2->4:2:0 convertion would be done on interlaced content, without being aware of this. This is likely to produce serious chroma artifacts. Considering that the avpicture_deinterlace ffmpeg function is supporting 4:2:2 (and higher) as input, extending the caps abilities of the ffdeinterlace and postproc_ffmpegdeint would allow to correctly deinterlace 4:2:2 content, which is not possible right now.
The only limitations seem to be that the pad template caps are hardcoded to I420. Modifiying title accordingly.
After further looking, in indeed appears that the ffmpeg pixel format is retrieved using gst_ffmpeg_caps_to_pixfmt, which translates Gstreamer caps into ffmpeg pixfmt. As gst_ffmpeg_caps_to_pixfmt already knows about 4:2:2, it also seems to me that the limitation is only coming form the fact that pad templates of ffdeinterlace and postproc_ffmpegdeint are hardcoded to I420.
Created attachment 100760 [details] [review] Overly simple patch Considering that ffmpeg is supporting 422P and 411P (http://lxr-itec.uni-klu.ac.at/ffmpeg/source/libavcodec/imgconvert.c#L2129), and considering that Gstreamer caps to ffmpeg formats conversion (gst_ffmpeg_caps_to_pixfmt within gstffmpegcodecmap.c) is able to convert Y42B and Y41B to those formats, wondering is something as simple as this patch could just work.
did someone try it?
I finally tryed it with this pipeline: gst-launch -v filesrc location=source.mpg ! mpegdemux ! mpeg2dec ! ffmpegcolorspace ! video/x-raw-yuv, format=\(fourcc\)Y42B ! postproc_ffmpegdeint ! ffmpegcolorspace ! videoscale ! autovideosink It works, and connects fine. It deinterlaces, but this pipeline still produces a few color artifacts. I think that it's likely because I'm using ffmpegcolorspace to convert 4:2:0 interlaced video into 4:2:2, while ffmpegcolorspace is not interlacing-aware.
I just tryed with a 4:2:2 mpeg source, and indeed it appears to work properly.
2008-05-06 Edward Hervey <edward.hervey@collabora.co.uk> Patch by: Gabriel Bouvigne <bouvigne at mp3-tech dot org> * ext/libpostproc/gstpostproc.c: Support for non-I420 colorspaces in postproc Fixes #496127