.depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_RGB32] = {
- .name = "rgb32",
+ [PIX_FMT_ARGB] = {
+ .name = "argb",
.nb_channels = 4, .is_alpha = 1,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 16,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_RGB565] = {
- .name = "rgb565",
+ [PIX_FMT_RGB565BE] = {
+ .name = "rgb565be",
.nb_channels = 3,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 5,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_RGB555] = {
- .name = "rgb555",
+ [PIX_FMT_RGB565LE] = {
+ .name = "rgb565le",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
+ },
+ [PIX_FMT_RGB555BE] = {
+ .name = "rgb555be",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
+ },
+ [PIX_FMT_RGB555LE] = {
+ .name = "rgb555le",
.nb_channels = 3,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 8,
.x_chroma_shift = 2, .y_chroma_shift = 0,
},
- [PIX_FMT_BGR32] = {
- .name = "bgr32",
+ [PIX_FMT_ABGR] = {
+ .name = "abgr",
.nb_channels = 4, .is_alpha = 1,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_BGR565] = {
- .name = "bgr565",
+ [PIX_FMT_BGR565BE] = {
+ .name = "bgr565be",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
+ },
+ [PIX_FMT_BGR565LE] = {
+ .name = "bgr565le",
.nb_channels = 3,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 5,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_BGR555] = {
- .name = "bgr555",
+ [PIX_FMT_BGR555BE] = {
+ .name = "bgr555be",
+ .nb_channels = 3,
+ .color_type = FF_COLOR_RGB,
+ .pixel_type = FF_PIXEL_PACKED,
+ .depth = 5,
+ .x_chroma_shift = 0, .y_chroma_shift = 0,
+ },
+ [PIX_FMT_BGR555LE] = {
+ .name = "bgr555le",
.nb_channels = 3,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.x_chroma_shift = 1, .y_chroma_shift = 1,
},
- [PIX_FMT_BGR32_1] = {
- .name = "bgr32_1",
+ [PIX_FMT_BGRA] = {
+ .name = "bgra",
.nb_channels = 4, .is_alpha = 1,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
.depth = 8,
.x_chroma_shift = 0, .y_chroma_shift = 0,
},
- [PIX_FMT_RGB32_1] = {
- .name = "rgb32_1",
+ [PIX_FMT_RGBA] = {
+ .name = "rgba",
.nb_channels = 4, .is_alpha = 1,
.color_type = FF_COLOR_RGB,
.pixel_type = FF_PIXEL_PACKED,
},
};
-void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift)
+void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift)
{
*h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
*v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
}
-const char *avcodec_get_pix_fmt_name(int pix_fmt)
+const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt)
{
if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
return NULL;
return pix_fmt_info[pix_fmt].name;
}
-enum PixelFormat avcodec_get_pix_fmt(const char* name)
+static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name)
{
int i;
for (i=0; i < PIX_FMT_NB; i++)
- if (!strcmp(pix_fmt_info[i].name, name))
- return i;
+ if (pix_fmt_info[i].name && !strcmp(pix_fmt_info[i].name, name))
+ return i;
return PIX_FMT_NONE;
}
-void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt)
+#ifdef WORDS_BIGENDIAN
+# define X_NE(be, le) be
+#else
+# define X_NE(be, le) le
+#endif
+
+enum PixelFormat avcodec_get_pix_fmt(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");
+
+ pix_fmt = avcodec_get_pix_fmt_internal(name);
+ if (pix_fmt == PIX_FMT_NONE) {
+ char name2[32];
+ snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
+ pix_fmt = avcodec_get_pix_fmt_internal(name2);
+ }
+ return pix_fmt;
+}
+
+void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
{
/* print header */
if (pix_fmt < 0)
return 0;
}
-int ff_fill_linesize(AVPicture *picture, int pix_fmt, int width)
+int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
{
int w2;
const PixFmtInfo *pinfo;
case PIX_FMT_BGR24:
picture->linesize[0] = width * 3;
break;
- case PIX_FMT_RGB32:
- case PIX_FMT_BGR32:
- case PIX_FMT_RGB32_1:
- case PIX_FMT_BGR32_1:
+ case PIX_FMT_ARGB:
+ case PIX_FMT_ABGR:
+ case PIX_FMT_RGBA:
+ case PIX_FMT_BGRA:
picture->linesize[0] = width * 4;
break;
case PIX_FMT_RGB48BE:
return 0;
}
-int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, int pix_fmt,
+int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
int height)
{
int size, h2, size2;
return size + 2 * size2;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
- case PIX_FMT_RGB32:
- case PIX_FMT_BGR32:
- case PIX_FMT_RGB32_1:
- case PIX_FMT_BGR32_1:
+ case PIX_FMT_ARGB:
+ case PIX_FMT_ABGR:
+ case PIX_FMT_RGBA:
+ case PIX_FMT_BGRA:
case PIX_FMT_RGB48BE:
case PIX_FMT_RGB48LE:
case PIX_FMT_GRAY16BE:
}
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
- int pix_fmt, int width, int height)
+ enum PixelFormat pix_fmt, int width, int height)
{
if(avcodec_check_dimensions(NULL, width, height))
return ff_fill_pointer(picture, ptr, pix_fmt, height);
}
-int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
+int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
const PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
return size;
}
-int avpicture_get_size(int pix_fmt, int width, int height)
+int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
{
AVPicture dummy_pict;
+ if(avcodec_check_dimensions(NULL, width, height))
+ return -1;
+ switch (pix_fmt) {
+ case PIX_FMT_RGB8:
+ case PIX_FMT_BGR8:
+ case PIX_FMT_RGB4_BYTE:
+ case PIX_FMT_BGR4_BYTE:
+ case PIX_FMT_GRAY8:
+ // do not include palette for these pseudo-paletted formats
+ return width * height;
+ }
return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
}
-int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
+int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
int has_alpha)
{
const PixFmtInfo *pf, *ps;
int loss;
ps = &pix_fmt_info[src_pix_fmt];
- pf = &pix_fmt_info[dst_pix_fmt];
/* compute loss */
loss = 0;
return loss;
}
-static int avg_bits_per_pixel(int pix_fmt)
+static int avg_bits_per_pixel(enum PixelFormat pix_fmt)
{
int bits;
const PixFmtInfo *pf;
return bits;
}
-static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
- int src_pix_fmt,
+static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
+ enum PixelFormat src_pix_fmt,
int has_alpha,
int loss_mask)
{
- int dist, i, loss, min_dist, dst_pix_fmt;
+ int dist, i, loss, min_dist;
+ enum PixelFormat dst_pix_fmt;
/* find exact color match with smallest size */
dst_pix_fmt = -1;
return dst_pix_fmt;
}
-int avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, int src_pix_fmt,
+enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
int has_alpha, int *loss_ptr)
{
- int dst_pix_fmt, loss_mask, i;
+ enum PixelFormat dst_pix_fmt;
+ int loss_mask, i;
static const int loss_mask_order[] = {
~0, /* no loss first */
~FF_LOSS_ALPHA,
}
void av_picture_copy(AVPicture *dst, const AVPicture *src,
- int pix_fmt, int width, int height)
+ enum PixelFormat pix_fmt, int width, int height)
{
int i;
const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
- pf = &pix_fmt_info[pix_fmt];
switch(pf->pixel_type) {
case FF_PIXEL_PACKED:
case FF_PIXEL_PLANAR:
int avpicture_alloc(AVPicture *picture,
- int pix_fmt, int width, int height)
+ enum PixelFormat pix_fmt, int width, int height)
{
int size;
void *ptr;
- size = avpicture_get_size(pix_fmt, width, height);
+ size = avpicture_fill(picture, NULL, pix_fmt, width, height);
if(size<0)
goto fail;
ptr = av_malloc(size);
}
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
- int pix_fmt, int padtop, int padbottom, int padleft, int padright,
+ enum PixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color)
{
uint8_t *optr;
}
int img_get_alpha_info(const AVPicture *src,
- int pix_fmt, int width, int height)
+ enum PixelFormat pix_fmt, int width, int height)
{
const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
int ret;
}
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
- int pix_fmt, int width, int height)
+ enum PixelFormat pix_fmt, int width, int height)
{
int i;