]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/imgconvert.c
Updated Makefile.omk for libswscale.
[frescor/ffmpeg.git] / libavcodec / imgconvert.c
index 8619b40336a8cbf56afc6b89ed8f2bb1c5f2490f..3f457fe7578d87028869e77efdf548341ed89ee0 100644 (file)
@@ -130,6 +130,55 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
         .depth = 8,
         .x_chroma_shift = 0, .y_chroma_shift = 1,
     },
+    [PIX_FMT_YUV420PLE] = {
+        .name = "yuv420ple",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
+    },
+    [PIX_FMT_YUV422PLE] = {
+        .name = "yuv422ple",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 1, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_YUV444PLE] = {
+        .name = "yuv444ple",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_YUV420PBE] = {
+        .name = "yuv420pbe",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
+    },
+    [PIX_FMT_YUV422PBE] = {
+        .name = "yuv422pbe",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 1, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_YUV444PBE] = {
+        .name = "yuv444pbe",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_YUV,
+        .pixel_type = FF_PIXEL_PLANAR,
+        .depth = 16,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+
 
     /* YUV formats with alpha plane */
     [PIX_FMT_YUVA420P] = {
@@ -192,8 +241,8 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
         .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,
@@ -216,16 +265,32 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
         .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_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_RGB555] = {
-        .name = "rgb555",
+    [PIX_FMT_RGB555LE] = {
+        .name = "rgb555le",
         .nb_channels = 3,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
@@ -319,24 +384,40 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
         .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,
@@ -408,16 +489,16 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
         .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,
@@ -462,27 +543,33 @@ 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;
 }
 
-enum PixelFormat avcodec_get_pix_fmt(const char *name)
-{
 #ifdef WORDS_BIGENDIAN
-#   define NE "be"
+#   define X_NE(be, le) be
 #else
-#   define NE "le"
+#   define X_NE(be, le) le
 #endif
-    enum PixelFormat pix_fmt = avcodec_get_pix_fmt_internal(name);
 
+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, NE);
+        snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
         pix_fmt = avcodec_get_pix_fmt_internal(name2);
     }
     return pix_fmt;
-#undef NE
 }
 
 void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
@@ -575,6 +662,17 @@ int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
         picture->linesize[1] = w2;
         picture->linesize[2] = w2;
         break;
+    case PIX_FMT_YUV420PLE:
+    case PIX_FMT_YUV422PLE:
+    case PIX_FMT_YUV444PLE:
+    case PIX_FMT_YUV420PBE:
+    case PIX_FMT_YUV422PBE:
+    case PIX_FMT_YUV444PBE:
+        w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
+        picture->linesize[0] = 2*width;
+        picture->linesize[1] = 2*w2;
+        picture->linesize[2] = 2*w2;
+        break;
     case PIX_FMT_YUVA420P:
         w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
         picture->linesize[0] = width;
@@ -592,10 +690,10 @@ int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
     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:
@@ -658,6 +756,12 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
     case PIX_FMT_YUVJ422P:
     case PIX_FMT_YUVJ444P:
     case PIX_FMT_YUVJ440P:
+    case PIX_FMT_YUV420PLE:
+    case PIX_FMT_YUV422PLE:
+    case PIX_FMT_YUV444PLE:
+    case PIX_FMT_YUV420PBE:
+    case PIX_FMT_YUV422PBE:
+    case PIX_FMT_YUV444PBE:
         h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
         size2 = picture->linesize[1] * h2;
         picture->data[0] = ptr;
@@ -684,10 +788,10 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
         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:
@@ -825,7 +929,6 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
     int loss;
 
     ps = &pix_fmt_info[src_pix_fmt];
-    pf = &pix_fmt_info[dst_pix_fmt];
 
     /* compute loss */
     loss = 0;
@@ -1035,7 +1138,6 @@ void av_picture_copy(AVPicture *dst, const AVPicture *src,
     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:
@@ -1299,7 +1401,6 @@ int img_get_alpha_info(const AVPicture *src,
     const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
     int ret;
 
-    pf = &pix_fmt_info[pix_fmt];
     /* no alpha can be represented in format */
     if (!pf->is_alpha)
         return 0;