History

Implement av_get_pix_fmt(), and deprecate avcodec_get_pix_fmt().

Originally committed as revision 21545 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 16 years ago

Commit 80a07f61 parent 7b0b81a5 files · +59 −32Browse files

Unified · Split

5 files
  1. libavcodec/avcodec.h +5 −1
  2. libavcodec/imgconvert.c +3 −30
  3. libavutil/avutil.h +1 −1
  4. libavutil/pixdesc.c +37 −0
  5. libavutil/pixdesc.h +13 −0
libavcodec/avcodec.h+5−1
@@ -2995,6 +2995,7 @@ void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int * · 2994 unmodified lines
29952995 const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
29962996 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
29972997
2998+#if LIBAVCODEC_VERSION_MAJOR < 53
29982999 /**
29993000 * Returns the pixel format corresponding to the name name.
30003001 *
@@ -3005,8 +3006,11 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height); · 4 unmodified lines
30053006 * then for "gray16le".
30063007 *
30073008 * Finally if no pixel format has been found, returns PIX_FMT_NONE.
3009+ *
3010+ * @deprecated Deprecated in favor of av_get_pix_fmt().
30083011 */
3009−enum PixelFormat avcodec_get_pix_fmt(const char* name);
3012+attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name);
3013+#endif
30103014
30113015 /**
30123016 * Returns a value representing the fourCC code associated to the
libavcodec/imgconvert.c+3−30
@@ -391,39 +391,12 @@ const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt) · 390 unmodified lines
391391 return av_pix_fmt_descriptors[pix_fmt].name;
392392 }
393393
394−static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name)
395−{
396− int i;
397−
398− for (i=0; i < PIX_FMT_NB; i++)
399− if (av_pix_fmt_descriptors[i].name && !strcmp(av_pix_fmt_descriptors[i].name, name))
400− return i;
401− return PIX_FMT_NONE;
402−}
403−
404−#if HAVE_BIGENDIAN
405−# define X_NE(be, le) be
406−#else
407−# define X_NE(be, le) le
408−#endif
409−
394+#if LIBAVCODEC_VERSION_MAJOR < 53
410395 enum PixelFormat avcodec_get_pix_fmt(const char *name)
411396 {
412− enum PixelFormat pix_fmt;
413−
414− if (!strcmp(name, "rgb32"))
415− name = X_NE("argb", "bgra");
416− else if (!strcmp(name, "bgr32"))
417− name = X_NE("abgr", "rgba");
418−
419− pix_fmt = avcodec_get_pix_fmt_internal(name);
420− if (pix_fmt == PIX_FMT_NONE) {
421− char name2[32];
422− snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
423− pix_fmt = avcodec_get_pix_fmt_internal(name2);
424− }
425− return pix_fmt;
397+ return av_get_pix_fmt(name);
426398 }
399+#endif
427400
428401 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
429402 {
libavutil/avutil.h+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 50
43−#define LIBAVUTIL_VERSION_MINOR 7
43+#define LIBAVUTIL_VERSION_MINOR 8
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
libavutil/pixdesc.c+37−0
@@ -654,6 +654,43 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = { · 653 unmodified lines
654654 },
655655 };
656656
657+static enum PixelFormat get_pix_fmt_internal(const char *name)
658+{
659+ enum PixelFormat pix_fmt;
660+
661+ for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
662+ if (av_pix_fmt_descriptors[pix_fmt].name &&
663+ !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
664+ return pix_fmt;
665+
666+ return PIX_FMT_NONE;
667+}
668+
669+#if HAVE_BIGENDIAN
670+# define X_NE(be, le) be
671+#else
672+# define X_NE(be, le) le
673+#endif
674+
675+enum PixelFormat av_get_pix_fmt(const char *name)
676+{
677+ enum PixelFormat pix_fmt;
678+
679+ if (!strcmp(name, "rgb32"))
680+ name = X_NE("argb", "bgra");
681+ else if (!strcmp(name, "bgr32"))
682+ name = X_NE("abgr", "rgba");
683+
684+ pix_fmt = get_pix_fmt_internal(name);
685+ if (pix_fmt == PIX_FMT_NONE) {
686+ char name2[32];
687+
688+ snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
689+ pix_fmt = get_pix_fmt_internal(name2);
690+ }
691+ return pix_fmt;
692+}
693+
657694 int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
658695 {
659696 int c, bits = 0;
libavutil/pixdesc.h+13−0
@@ -202,6 +202,19 @@ static inline void write_line(const uint16_t *src, uint8_t *data[4], const int l · 201 unmodified lines
202202 }
203203 }
204204
205+/**
206+ * Returns the pixel format corresponding to name.
207+ *
208+ * If there is no pixel format with name name, then looks for a
209+ * pixel format with the name corresponding to the native endian
210+ * format of name.
211+ * For example in a little-endian system, first looks for "gray16",
212+ * then for "gray16le".
213+ *
214+ * Finally if no pixel format has been found, returns PIX_FMT_NONE.
215+ */
216+enum PixelFormat av_get_pix_fmt(const char *name);
217+
205218 /**
206219 * Returns the number of bits per pixel used by the pixel format
207220 * described by pixdesc.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t