[PATCH] Implement av_get_pix_fmt_by_name()
Hi, as in subject. This is going to replace avcodec_get_pix_fmt(). Regards. -- FFmpeg = Frenzy & Fierce Mind-dumbing Patchable Erotic Guide
On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
Hi,
as in subject.
This is going to replace avcodec_get_pix_fmt().
Patch updated and slightly changed, now it should be intended as a move of the code of avcodec_get_pix_fmt() to libavutil. Regards. -- FFmpeg = Free & Fostering Mournful Porno Extroverse Gymnast
On date Thursday 2009-11-26 22:45:31 +0100, Stefano Sabatini encoded:
On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
Hi,
as in subject.
This is going to replace avcodec_get_pix_fmt().
Patch updated and slightly changed, now it should be intended as a move of the code of avcodec_get_pix_fmt() to libavutil.
Ping (I need this, my idea is to make swscale-test take in input IN OUT as a format, should help when debugging conversion code without to rely on lavfi). Regards. -- FFmpeg = Fantastic and Fierce Mystic Pitiful Erudite Genius
On 01/27/2010 05:10 PM, Stefano Sabatini wrote:
On date Thursday 2009-11-26 22:45:31 +0100, Stefano Sabatini encoded:
On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
Hi,
as in subject.
This is going to replace avcodec_get_pix_fmt().
Patch updated and slightly changed, now it should be intended as a move of the code of avcodec_get_pix_fmt() to libavutil.
Ping (I need this, my idea is to make swscale-test take in input IN OUT as a format, should help when debugging conversion code without to rely on lavfi).
Regards.
implement-get-pix-fmt-by-name.patch
Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2009-11-29 10:47:45.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2009-11-29 11:04:14.000000000 +0100 @@ -648,6 +648,43 @@ }, };
+enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
Missing static. [...] -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
On date Wednesday 2010-01-27 17:28:04 -0800, Baptiste Coudurier encoded:
On 01/27/2010 05:10 PM, Stefano Sabatini wrote:
On date Thursday 2009-11-26 22:45:31 +0100, Stefano Sabatini encoded:
On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
Hi,
as in subject.
This is going to replace avcodec_get_pix_fmt().
Patch updated and slightly changed, now it should be intended as a move of the code of avcodec_get_pix_fmt() to libavutil.
Ping (I need this, my idea is to make swscale-test take in input IN OUT as a format, should help when debugging conversion code without to rely on lavfi).
Regards.
implement-get-pix-fmt-by-name.patch
Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2009-11-29 10:47:45.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2009-11-29 11:04:14.000000000 +0100 @@ -648,6 +648,43 @@ }, };
+enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
Missing static.
Updated. -- FFmpeg = Fast & Foolish Moronic Philosophical Eager Gargoyle
On Thu, Jan 28, 2010 at 10:38:03PM +0100, Stefano Sabatini wrote:
On date Wednesday 2010-01-27 17:28:04 -0800, Baptiste Coudurier encoded:
On 01/27/2010 05:10 PM, Stefano Sabatini wrote:
On date Thursday 2009-11-26 22:45:31 +0100, Stefano Sabatini encoded:
On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
Hi,
as in subject.
This is going to replace avcodec_get_pix_fmt().
Patch updated and slightly changed, now it should be intended as a move of the code of avcodec_get_pix_fmt() to libavutil.
Ping (I need this, my idea is to make swscale-test take in input IN OUT as a format, should help when debugging conversion code without to rely on lavfi).
Regards.
implement-get-pix-fmt-by-name.patch
Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2009-11-29 10:47:45.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2009-11-29 11:04:14.000000000 +0100 @@ -648,6 +648,43 @@ }, };
+enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
Missing static.
Updated. -- FFmpeg = Fast & Foolish Moronic Philosophical Eager Gargoyle
libavcodec/avcodec.h | 4 ++++ libavcodec/imgconvert.c | 33 +++------------------------------ libavutil/pixdesc.c | 37 +++++++++++++++++++++++++++++++++++++ libavutil/pixdesc.h | 13 +++++++++++++ 4 files changed, 57 insertions(+), 30 deletions(-) f3e4d5070216d22c0cd6cbc289660ea1c13b804a implement-get-pix-fmt-by-name.patch Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2010-01-20 19:52:08.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2010-01-28 22:35:17.000000000 +0100 @@ -654,6 +654,43 @@ }, };
+static enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
static functions should not have av prefixes
+{ + enum PixelFormat pix_fmt; + + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) + if (av_pix_fmt_descriptors[pix_fmt].name && + !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name)) + return pix_fmt; + + return PIX_FMT_NONE; +} + +#if HAVE_BIGENDIAN +# define X_NE(be, le) be +#else +# define X_NE(be, le) le +#endif + +enum PixelFormat av_get_pix_fmt_by_name(const char *name) +{ + enum PixelFormat pix_fmt; + + if (!strcmp(name, "rgb32")) + name = X_NE("argb", "bgra"); + else if (!strcmp(name, "bgr32")) + name = X_NE("abgr", "rgba");
this list is not complete also its quite easy to add a new format and forget this list [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Freedom in capitalist society always remains about the same as it was in ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
On date Thursday 2010-01-28 23:22:03 +0100, Michael Niedermayer encoded:
On Thu, Jan 28, 2010 at 10:38:03PM +0100, Stefano Sabatini wrote: [...]
f3e4d5070216d22c0cd6cbc289660ea1c13b804a implement-get-pix-fmt-by-name.patch Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2010-01-20 19:52:08.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2010-01-28 22:35:17.000000000 +0100 @@ -654,6 +654,43 @@ }, };
+static enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
static functions should not have av prefixes
+{ + enum PixelFormat pix_fmt; + + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) + if (av_pix_fmt_descriptors[pix_fmt].name && + !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name)) + return pix_fmt; + + return PIX_FMT_NONE; +} + +#if HAVE_BIGENDIAN +# define X_NE(be, le) be +#else +# define X_NE(be, le) le +#endif + +enum PixelFormat av_get_pix_fmt_by_name(const char *name) +{ + enum PixelFormat pix_fmt; + + if (!strcmp(name, "rgb32")) + name = X_NE("argb", "bgra"); + else if (!strcmp(name, "bgr32")) + name = X_NE("abgr", "rgba");
this list is not complete also its quite easy to add a new format and forget this list
mmh this is what is currently supported, we left those definitions for a precise reason: ------------------------------------------------------------------------ r18163 | stefano | 2009-03-22 23:50:19 +0100 (Sun, 22 Mar 2009) | 19 lines Make the pixel formats which were defined as macros: PIX_FMT_ARGB PIX_FMT_RGBA PIX_FMT_ABGR PIX_FMT_BGRA defined as enum PixelFormat values, and viceversa make: PIX_FMT_RGB32 PIX_FMT_RGB32_1 PIX_FMT_BGR32 PIX_FMT_BGR32_1 defined as macros, also resort accordingly the enum PixelFormat list. Also make avcodec_get_pix_fmt() recognize the "rgb32" and "bgr32" aliases, in order to make ffmpeg pass regressions test. This change breaks ABI backward compatibility. ------------------------------------------------------------------------ Please elaborate, new patch attached, regards. -- FFmpeg = Freak and Faithless Mind-dumbing Portable Epic Game
On Fri, Jan 29, 2010 at 12:05:05AM +0100, Stefano Sabatini wrote:
On date Thursday 2010-01-28 23:22:03 +0100, Michael Niedermayer encoded:
On Thu, Jan 28, 2010 at 10:38:03PM +0100, Stefano Sabatini wrote: [...]
f3e4d5070216d22c0cd6cbc289660ea1c13b804a implement-get-pix-fmt-by-name.patch Index: ffmpeg/libavutil/pixdesc.c =================================================================== --- ffmpeg.orig/libavutil/pixdesc.c 2010-01-20 19:52:08.000000000 +0100 +++ ffmpeg/libavutil/pixdesc.c 2010-01-28 22:35:17.000000000 +0100 @@ -654,6 +654,43 @@ }, };
+static enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
static functions should not have av prefixes
+{ + enum PixelFormat pix_fmt; + + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) + if (av_pix_fmt_descriptors[pix_fmt].name && + !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name)) + return pix_fmt; + + return PIX_FMT_NONE; +} + +#if HAVE_BIGENDIAN +# define X_NE(be, le) be +#else +# define X_NE(be, le) le +#endif + +enum PixelFormat av_get_pix_fmt_by_name(const char *name) +{ + enum PixelFormat pix_fmt; + + if (!strcmp(name, "rgb32")) + name = X_NE("argb", "bgra"); + else if (!strcmp(name, "bgr32")) + name = X_NE("abgr", "rgba");
this list is not complete also its quite easy to add a new format and forget this list
mmh this is what is currently supported, we left those definitions for a precise reason: ------------------------------------------------------------------------ r18163 | stefano | 2009-03-22 23:50:19 +0100 (Sun, 22 Mar 2009) | 19 lines
Make the pixel formats which were defined as macros: PIX_FMT_ARGB PIX_FMT_RGBA PIX_FMT_ABGR PIX_FMT_BGRA
defined as enum PixelFormat values, and viceversa make: PIX_FMT_RGB32 PIX_FMT_RGB32_1 PIX_FMT_BGR32 PIX_FMT_BGR32_1
defined as macros, also resort accordingly the enum PixelFormat list. Also make avcodec_get_pix_fmt() recognize the "rgb32" and "bgr32" aliases, in order to make ffmpeg pass regressions test.
This change breaks ABI backward compatibility. ------------------------------------------------------------------------
Please elaborate, new patch attached, regards. -- FFmpeg = Freak and Faithless Mind-dumbing Portable Epic Game
libavcodec/avcodec.h | 4 ++++ libavcodec/imgconvert.c | 33 +++------------------------------ libavutil/pixdesc.c | 37 +++++++++++++++++++++++++++++++++++++ libavutil/pixdesc.h | 13 +++++++++++++ 4 files changed, 57 insertions(+), 30 deletions(-) e5e9c160bfb1e22ea556ae29a1b550288d09b184 implement-get-pix-fmt-by-name.patch
if it makes you happy, ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin
On date Friday 2010-01-29 01:19:36 +0100, Michael Niedermayer encoded:
On Fri, Jan 29, 2010 at 12:05:05AM +0100, Stefano Sabatini wrote: [...]
e5e9c160bfb1e22ea556ae29a1b550288d09b184 implement-get-pix-fmt-by-name.patch
if it makes you happy, ok
Just another question, does someone have arguments for preferring av_get_pix_fmt() rather than av_get_pix_fmt_by_name() ? The latter is less ambiguous, but looks too much long. Regards. -- FFmpeg = Fast and Fundamental Multimedia Portentous Elastic Guru
On Sat, Jan 30, 2010 at 11:35:47AM +0100, Stefano Sabatini wrote:
On date Friday 2010-01-29 01:19:36 +0100, Michael Niedermayer encoded:
On Fri, Jan 29, 2010 at 12:05:05AM +0100, Stefano Sabatini wrote: [...]
e5e9c160bfb1e22ea556ae29a1b550288d09b184 implement-get-pix-fmt-by-name.patch
if it makes you happy, ok
Just another question, does someone have arguments for preferring
av_get_pix_fmt() rather than av_get_pix_fmt_by_name() ?
av_name2pix_fmt() if the len bothers you [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
On date Saturday 2010-01-30 13:25:09 +0100, Michael Niedermayer encoded:
On Sat, Jan 30, 2010 at 11:35:47AM +0100, Stefano Sabatini wrote:
On date Friday 2010-01-29 01:19:36 +0100, Michael Niedermayer encoded:
On Fri, Jan 29, 2010 at 12:05:05AM +0100, Stefano Sabatini wrote: [...]
e5e9c160bfb1e22ea556ae29a1b550288d09b184 implement-get-pix-fmt-by-name.patch
if it makes you happy, ok
Just another question, does someone have arguments for preferring
av_get_pix_fmt() rather than av_get_pix_fmt_by_name() ?
av_name2pix_fmt() if the len bothers you
Ugh, that's ugly... ./libpostproc/postprocess.h:90:pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality); ./libavfilter/avfilter.h:611:AVFilter *avfilter_get_by_name(const char *name); ./libavcodec/avcodec.h:3162:AVCodec *avcodec_find_encoder_by_name(const char *name); ./libavcodec/avcodec.h:3178:AVCodec *avcodec_find_decoder_by_name(const char *name); but also: av_find_input_format() so maybe another solution: av_find_pix_fmt_by_name() or: av_find_pix_fmt() since there is currently no way to find/get a pixel format but by name. But then I have no strong preference amongst these ones: av_find_pix_fmt_by_name() av_find_pix_fmt() av_get_pix_fmt() av_get_pix_fmt_by_name() for this reason I wanted to hear if others have preferences+arguments, otherwise I think I'll go for the shortest variant (av_get_pix_fmt). Regards. -- FFmpeg = Furious Fast Mournful Programmable Egregious Geek
On Sat, Jan 30, 2010 at 01:53:27PM +0100, Stefano Sabatini wrote:
On date Saturday 2010-01-30 13:25:09 +0100, Michael Niedermayer encoded: [...] av_find_pix_fmt_by_name() av_find_pix_fmt() av_get_pix_fmt() av_get_pix_fmt_by_name()
i prefer get over find [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time.
On date Saturday 2010-01-30 15:04:45 +0100, Michael Niedermayer encoded:
On Sat, Jan 30, 2010 at 01:53:27PM +0100, Stefano Sabatini wrote:
On date Saturday 2010-01-30 13:25:09 +0100, Michael Niedermayer encoded: [...] av_find_pix_fmt_by_name() av_find_pix_fmt() av_get_pix_fmt() av_get_pix_fmt_by_name()
i prefer get over find
I'll apply the av_get_pix_fmt() variant later then. Regards. -- FFmpeg = Free Fundamental Mournful Plastic Eager Geek
On date Saturday 2010-01-30 15:18:59 +0100, Stefano Sabatini encoded:
On date Saturday 2010-01-30 15:04:45 +0100, Michael Niedermayer encoded:
On Sat, Jan 30, 2010 at 01:53:27PM +0100, Stefano Sabatini wrote:
On date Saturday 2010-01-30 13:25:09 +0100, Michael Niedermayer encoded: [...] av_find_pix_fmt_by_name() av_find_pix_fmt() av_get_pix_fmt() av_get_pix_fmt_by_name()
i prefer get over find
I'll apply the av_get_pix_fmt() variant later then.
Applied. -- FFmpeg = Fascinating and Friendly MultiPurpose Ecstatic Generator
participants (3)
-
baptiste.coudurier@gmail.com -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it