summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavcodec/imgconvert.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libffmpeg/libavcodec/imgconvert.c')
-rw-r--r--src/libffmpeg/libavcodec/imgconvert.c97
1 files changed, 59 insertions, 38 deletions
diff --git a/src/libffmpeg/libavcodec/imgconvert.c b/src/libffmpeg/libavcodec/imgconvert.c
index 6a36c8558..f154e4437 100644
--- a/src/libffmpeg/libavcodec/imgconvert.c
+++ b/src/libffmpeg/libavcodec/imgconvert.c
@@ -236,7 +236,7 @@ enum PixelFormat avcodec_get_pix_fmt(const char* name)
/* Picture field are filled with 'ptr' addresses. Also return size */
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
- int pix_fmt, int width, int height)
+ int pix_fmt, int width, int height)
{
int size, w2, h2, size2;
PixFmtInfo *pinfo;
@@ -313,12 +313,12 @@ int avpicture_fill(AVPicture *picture, uint8_t *ptr,
}
}
-int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
+int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
int i, j, w, h, data_planes;
- unsigned char* s;
+ const unsigned char* s;
int size = avpicture_get_size(pix_fmt, width, height);
if (size > dest_size)
@@ -535,7 +535,7 @@ static void img_copy_plane(uint8_t *dst, int dst_wrap,
/**
* Copy image 'src' to 'dst'.
*/
-void img_copy(AVPicture *dst, AVPicture *src,
+void img_copy(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int bwidth, bits, i;
@@ -588,24 +588,24 @@ void img_copy(AVPicture *dst, AVPicture *src,
/* XXX: totally non optimized */
-static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
+static void yuv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
- int x;
+ int w;
p1 = src->data[0];
lum1 = dst->data[0];
cb1 = dst->data[1];
cr1 = dst->data[2];
- for(;height >= 2; height -= 2) {
+ for(;height >= 1; height -= 2) {
p = p1;
lum = lum1;
cb = cb1;
cr = cr1;
- for(x=0;x<width;x+=2) {
+ for(w = width; w >= 2; w -= 2) {
lum[0] = p[0];
cb[0] = p[1];
lum[1] = p[2];
@@ -615,24 +615,36 @@ static void yuv422_to_yuv420p(AVPicture *dst, AVPicture *src,
cb++;
cr++;
}
- p1 += src->linesize[0];
- lum1 += dst->linesize[0];
- p = p1;
- lum = lum1;
- for(x=0;x<width;x+=2) {
+ if (w) {
lum[0] = p[0];
- lum[1] = p[2];
- p += 4;
- lum += 2;
+ cb[0] = p[1];
+ cr[0] = p[3];
+ cb++;
+ cr++;
}
p1 += src->linesize[0];
lum1 += dst->linesize[0];
+ if (height>1) {
+ p = p1;
+ lum = lum1;
+ for(w = width; w >= 2; w -= 2) {
+ lum[0] = p[0];
+ lum[1] = p[2];
+ p += 4;
+ lum += 2;
+ }
+ if (w) {
+ lum[0] = p[0];
+ }
+ p1 += src->linesize[0];
+ lum1 += dst->linesize[0];
+ }
cb1 += dst->linesize[1];
cr1 += dst->linesize[2];
}
}
-static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
+static void yuv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
int width, int height)
{
const uint8_t *p, *p1;
@@ -665,7 +677,7 @@ static void yuv422_to_yuv422p(AVPicture *dst, AVPicture *src,
}
}
-static void yuv422p_to_yuv422(AVPicture *dst, AVPicture *src,
+static void yuv422p_to_yuv422(AVPicture *dst, const AVPicture *src,
int width, int height)
{
uint8_t *p, *p1;
@@ -1274,7 +1286,7 @@ static inline unsigned int bitcopy_n(unsigned int a, int n)
#include "imgconvert_template.h"
-static void mono_to_gray(AVPicture *dst, AVPicture *src,
+static void mono_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
const unsigned char *p;
@@ -1315,19 +1327,19 @@ static void mono_to_gray(AVPicture *dst, AVPicture *src,
}
}
-static void monowhite_to_gray(AVPicture *dst, AVPicture *src,
+static void monowhite_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0xff);
}
-static void monoblack_to_gray(AVPicture *dst, AVPicture *src,
+static void monoblack_to_gray(AVPicture *dst, const AVPicture *src,
int width, int height)
{
mono_to_gray(dst, src, width, height, 0x00);
}
-static void gray_to_mono(AVPicture *dst, AVPicture *src,
+static void gray_to_mono(AVPicture *dst, const AVPicture *src,
int width, int height, int xor_mask)
{
int n;
@@ -1371,20 +1383,21 @@ static void gray_to_mono(AVPicture *dst, AVPicture *src,
}
}
-static void gray_to_monowhite(AVPicture *dst, AVPicture *src,
+static void gray_to_monowhite(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0xff);
}
-static void gray_to_monoblack(AVPicture *dst, AVPicture *src,
+static void gray_to_monoblack(AVPicture *dst, const AVPicture *src,
int width, int height)
{
gray_to_mono(dst, src, width, height, 0x00);
}
typedef struct ConvertEntry {
- void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
+ void (*convert)(AVPicture *dst,
+ const AVPicture *src, int width, int height);
} ConvertEntry;
/* Add each new convertion function in this table. In order to be able
@@ -1600,7 +1613,7 @@ static ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
},
};
-static int avpicture_alloc(AVPicture *picture,
+int avpicture_alloc(AVPicture *picture,
int pix_fmt, int width, int height)
{
unsigned int size;
@@ -1617,7 +1630,7 @@ static int avpicture_alloc(AVPicture *picture,
return -1;
}
-static void avpicture_free(AVPicture *picture)
+void avpicture_free(AVPicture *picture)
{
av_free(picture->data[0]);
}
@@ -1632,7 +1645,7 @@ static inline int is_yuv_planar(PixFmtInfo *ps)
/* XXX: always use linesize. Return -1 if not supported */
int img_convert(AVPicture *dst, int dst_pix_fmt,
- AVPicture *src, int src_pix_fmt,
+ const AVPicture *src, int src_pix_fmt,
int src_width, int src_height)
{
static int inited;
@@ -1865,7 +1878,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
}
/* NOTE: we scan all the pixels to have an exact information */
-static int get_alpha_info_pal8(AVPicture *src, int width, int height)
+static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
{
const unsigned char *p;
int src_wrap, ret, x, y;
@@ -1894,7 +1907,8 @@ static int get_alpha_info_pal8(AVPicture *src, int width, int height)
* Tell if an image really has transparent alpha values.
* @return ored mask of FF_ALPHA_xxx constants
*/
-int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
+int img_get_alpha_info(const AVPicture *src,
+ int pix_fmt, int width, int height)
{
PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
int ret;
@@ -1969,8 +1983,11 @@ int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height)
#endif
/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line(uint8_t *dst, uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *lum_m2, uint8_t *lum_m1, uint8_t *lum,
- int size)
+static void deinterlace_line(uint8_t *dst,
+ const uint8_t *lum_m4, const uint8_t *lum_m3,
+ const uint8_t *lum_m2, const uint8_t *lum_m1,
+ const uint8_t *lum,
+ int size)
{
#ifndef HAVE_MMX
uint8_t *cm = cropTbl + MAX_NEG_CROP;
@@ -2059,10 +2076,10 @@ static void deinterlace_line_inplace(uint8_t *lum_m4, uint8_t *lum_m3, uint8_t *
top field is copied as is, but the bottom field is deinterlaced
against the top field. */
static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
- uint8_t *src1, int src_wrap,
+ const uint8_t *src1, int src_wrap,
int width, int height)
{
- uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
+ const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
int y;
src_m2 = src1;
@@ -2088,7 +2105,7 @@ static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
}
static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
- int width, int height)
+ int width, int height)
{
uint8_t *src_m1, *src_0, *src_p1, *src_p2;
int y;
@@ -2114,14 +2131,15 @@ static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
/* deinterlace - if not supported return -1 */
-int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
+int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
int pix_fmt, int width, int height)
{
int i;
if (pix_fmt != PIX_FMT_YUV420P &&
pix_fmt != PIX_FMT_YUV422P &&
- pix_fmt != PIX_FMT_YUV444P)
+ pix_fmt != PIX_FMT_YUV444P &&
+ pix_fmt != PIX_FMT_YUV411P)
return -1;
if ((width & 3) != 0 || (height & 3) != 0)
return -1;
@@ -2136,12 +2154,15 @@ int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
case PIX_FMT_YUV422P:
width >>= 1;
break;
+ case PIX_FMT_YUV411P:
+ width >>= 2;
+ break;
default:
break;
}
}
if (src == dst) {
- deinterlace_bottom_field_inplace(src->data[i], src->linesize[i],
+ deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i],
width, height);
} else {
deinterlace_bottom_field(dst->data[i],dst->linesize[i],