From de4a1aae917088d52779354d27748d8a186ac4e8 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 15:13:55 +0000 Subject: [PATCH 01/59] Add fflush to prevent stdout & stderr from being mixed. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27515 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale-example.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c index 79e21a922a..4bb42162ef 100644 --- a/libswscale/swscale-example.c +++ b/libswscale/swscale-example.c @@ -139,6 +139,7 @@ static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat sws_format_name(dstFormat), dstW, dstH, flags, ssdY, ssdU, ssdV); + fflush(stdout); } end: @@ -170,6 +171,7 @@ static void selfTest(uint8_t *src[3], int stride[3], int w, int h){ printf("%s -> %s\n", sws_format_name(srcFormat), sws_format_name(dstFormat)); + fflush(stdout); srcW= w; srcH= h; From b387cc68b66d6133240c84915743115bc104a4e2 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 18:14:29 +0000 Subject: [PATCH 02/59] Fix rgb15/16 vs. bgr part1. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27516 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/yuv2rgb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 83d65c5f2a..c177cba0c1 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -600,16 +600,16 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c) switch(c->dstFormat){ case PIX_FMT_RGB32: return yuv420_rgb32_MMX2; case PIX_FMT_BGR24: return yuv420_rgb24_MMX2; - case PIX_FMT_BGR565: return yuv420_rgb16_MMX2; - case PIX_FMT_BGR555: return yuv420_rgb15_MMX2; + case PIX_FMT_RGB565: return yuv420_rgb16_MMX2; + case PIX_FMT_RGB555: return yuv420_rgb15_MMX2; } } if (c->flags & SWS_CPU_CAPS_MMX){ switch(c->dstFormat){ case PIX_FMT_RGB32: return yuv420_rgb32_MMX; case PIX_FMT_BGR24: return yuv420_rgb24_MMX; - case PIX_FMT_BGR565: return yuv420_rgb16_MMX; - case PIX_FMT_BGR555: return yuv420_rgb15_MMX; + case PIX_FMT_RGB565: return yuv420_rgb16_MMX; + case PIX_FMT_RGB555: return yuv420_rgb15_MMX; } } #endif @@ -675,7 +675,14 @@ static int div_round (int dividend, int divisor) int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { - const int isRgb = isBGR(c->dstFormat); + const int isRgb = c->dstFormat==PIX_FMT_RGB32 + || c->dstFormat==PIX_FMT_BGR24 + || c->dstFormat==PIX_FMT_RGB565 + || c->dstFormat==PIX_FMT_RGB555 + || c->dstFormat==PIX_FMT_RGB8 + || c->dstFormat==PIX_FMT_RGB4 + || c->dstFormat==PIX_FMT_RGB4_BYTE + || c->dstFormat==PIX_FMT_MONOBLACK; const int bpp = fmt_depth(c->dstFormat); int i; uint8_t table_Y[1024]; From b8d98f89591df526184213dfbbf02505520eae73 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 18:24:25 +0000 Subject: [PATCH 03/59] Fix rgb15/16 vs. bgr part2. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27517 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale_template.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 1280ba6c02..fdb14fb0a1 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -705,7 +705,7 @@ " jb 1b \n\t" #define WRITEBGR32(dst, dstw, index) REAL_WRITEBGR32(dst, dstw, index) -#define REAL_WRITEBGR16(dst, dstw, index) \ +#define REAL_WRITERGB16(dst, dstw, index) \ "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\ "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ @@ -731,9 +731,9 @@ "add $8, "#index" \n\t"\ "cmp "#dstw", "#index" \n\t"\ " jb 1b \n\t" -#define WRITEBGR16(dst, dstw, index) REAL_WRITEBGR16(dst, dstw, index) +#define WRITERGB16(dst, dstw, index) REAL_WRITERGB16(dst, dstw, index) -#define REAL_WRITEBGR15(dst, dstw, index) \ +#define REAL_WRITERGB15(dst, dstw, index) \ "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\ "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\ "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\ @@ -760,7 +760,7 @@ "add $8, "#index" \n\t"\ "cmp "#dstw", "#index" \n\t"\ " jb 1b \n\t" -#define WRITEBGR15(dst, dstw, index) REAL_WRITEBGR15(dst, dstw, index) +#define WRITERGB15(dst, dstw, index) REAL_WRITERGB15(dst, dstw, index) #define WRITEBGR24OLD(dst, dstw, index) \ /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ @@ -1082,7 +1082,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S ); return; - case PIX_FMT_BGR555: + case PIX_FMT_RGB555: YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -1092,10 +1092,10 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ "paddusb "MANGLE(r5Dither)", %%mm5\n\t" #endif - WRITEBGR15(%4, %5, %%REGa) + WRITERGB15(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; - case PIX_FMT_BGR565: + case PIX_FMT_RGB565: YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -1105,7 +1105,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ "paddusb "MANGLE(r5Dither)", %%mm5\n\t" #endif - WRITEBGR16(%4, %5, %%REGa) + WRITERGB16(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_YUYV422: @@ -1142,7 +1142,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S ); return; - case PIX_FMT_BGR555: + case PIX_FMT_RGB555: YSCALEYUV2PACKEDX YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -1152,10 +1152,10 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR15(%4, %5, %%REGa) + WRITERGB15(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; - case PIX_FMT_BGR565: + case PIX_FMT_RGB565: YSCALEYUV2PACKEDX YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ @@ -1165,7 +1165,7 @@ static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_ "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR16(%4, %5, %%REGa) + WRITERGB16(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_YUYV422: @@ -1454,7 +1454,7 @@ FULL_YSCALEYUV2RGB "a" (&c->redDither) ); return; - case PIX_FMT_BGR555: + case PIX_FMT_RGB555: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1467,7 +1467,7 @@ FULL_YSCALEYUV2RGB "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" @@ -1475,7 +1475,7 @@ FULL_YSCALEYUV2RGB "a" (&c->redDither) ); return; - case PIX_FMT_BGR565: + case PIX_FMT_RGB565: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1488,7 +1488,7 @@ FULL_YSCALEYUV2RGB "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest), @@ -1565,7 +1565,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "a" (&c->redDither) ); return; - case PIX_FMT_BGR555: + case PIX_FMT_RGB555: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1577,7 +1577,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "paddusb "MANGLE(g5Dither)", %%mm4 \n\t" "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" @@ -1585,7 +1585,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "a" (&c->redDither) ); return; - case PIX_FMT_BGR565: + case PIX_FMT_RGB565: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1598,7 +1598,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" @@ -1654,7 +1654,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "a" (&c->redDither) ); return; - case PIX_FMT_BGR555: + case PIX_FMT_RGB555: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1666,7 +1666,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "paddusb "MANGLE(g5Dither)", %%mm4 \n\t" "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR15(%%REGb, 8280(%5), %%REGBP) + WRITERGB15(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" @@ -1674,7 +1674,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "a" (&c->redDither) ); return; - case PIX_FMT_BGR565: + case PIX_FMT_RGB565: asm volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" @@ -1687,7 +1687,7 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * "paddusb "MANGLE(r5Dither)", %%mm5 \n\t" #endif - WRITEBGR16(%%REGb, 8280(%5), %%REGBP) + WRITERGB16(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" From 6dcd5a4e7aecb5ee03297a1bb56871158aee9918 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 19:11:39 +0000 Subject: [PATCH 04/59] rgb vs bgr fix for the unscaled converters. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27518 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/rgb2rgb.c | 26 +++++++++++++------------- libswscale/rgb2rgb.h | 26 +++++++++++++------------- libswscale/rgb2rgb_template.c | 32 ++++++++++++++++---------------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 14c40700ce..6f935e997a 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -35,22 +35,22 @@ #define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients -void (*rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb32to16)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb32to15)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb15to16)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb16to24)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb16to32)(const uint8_t *src, uint8_t *dst, long src_size); //void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); -void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size); +void (*rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); //void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); @@ -330,7 +330,7 @@ void palette8tobgr15(const uint8_t *src, uint8_t *dst, long num_pixels, const ui ((uint16_t *)dst)[i] = bswap_16(((const uint16_t *)palette)[src[i]]); } -void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size) +void rgb32to24(const uint8_t *src, uint8_t *dst, long src_size) { long i; long num_pixels = src_size >> 2; @@ -349,7 +349,7 @@ void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size) } } -void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size) +void rgb24to32(const uint8_t *src, uint8_t *dst, long src_size) { long i; for (i=0; 3*i /* A full collection of RGB to RGB(BGR) converters */ -extern void (*rgb24to32) (const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb24to16) (const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb24to15) (const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb32to24) (const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb32to16) (const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb32to15) (const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb15to16) (const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb15to24) (const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb15to32) (const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb16to15) (const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb16to24) (const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb16to32) (const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); -extern void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb24to16) (const uint8_t *src, uint8_t *dst, long src_size); +extern void (*rgb24to15) (const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); extern void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long src_size); -extern void rgb24tobgr32(const uint8_t *src, uint8_t *dst, long src_size); -extern void rgb32tobgr24(const uint8_t *src, uint8_t *dst, long src_size); +extern void rgb24to32 (const uint8_t *src, uint8_t *dst, long src_size); +extern void rgb32to24 (const uint8_t *src, uint8_t *dst, long src_size); extern void rgb16tobgr32(const uint8_t *src, uint8_t *dst, long src_size); -extern void rgb16tobgr24(const uint8_t *src, uint8_t *dst, long src_size); +extern void rgb16to24 (const uint8_t *src, uint8_t *dst, long src_size); extern void rgb16tobgr16(const uint8_t *src, uint8_t *dst, long src_size); extern void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size); extern void rgb15tobgr32(const uint8_t *src, uint8_t *dst, long src_size); -extern void rgb15tobgr24(const uint8_t *src, uint8_t *dst, long src_size); +extern void rgb15to24 (const uint8_t *src, uint8_t *dst, long src_size); extern void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size); extern void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size); -extern void rgb8tobgr8 (const uint8_t *src, uint8_t *dst, long src_size); +extern void bgr8torgb8 (const uint8_t *src, uint8_t *dst, long src_size); extern void palette8torgb32(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette); diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c index ffbf2c734b..2f27f70a5d 100644 --- a/libswscale/rgb2rgb_template.c +++ b/libswscale/rgb2rgb_template.c @@ -82,7 +82,7 @@ #define SFENCE " # nop" #endif -static inline void RENAME(rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size) { uint8_t *dest = dst; const uint8_t *s = src; @@ -142,7 +142,7 @@ static inline void RENAME(rgb24to32)(const uint8_t *src, uint8_t *dst, long src_ } } -static inline void RENAME(rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, long src_size) { uint8_t *dest = dst; const uint8_t *s = src; @@ -657,7 +657,7 @@ static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, long s } } -static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; @@ -720,7 +720,7 @@ static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, long src_ } } -static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; @@ -783,7 +783,7 @@ static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long s } } -static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; @@ -846,7 +846,7 @@ static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, long src_ } } -static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size) { const uint8_t *s = src; const uint8_t *end; @@ -930,7 +930,7 @@ static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, long s | original bits */ -static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, long src_size) { const uint16_t *end; #ifdef HAVE_MMX @@ -1072,7 +1072,7 @@ static inline void RENAME(rgb15to24)(const uint8_t *src, uint8_t *dst, long src_ } } -static inline void RENAME(rgb16to24)(const uint8_t *src, uint8_t *dst, long src_size) +static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, long src_size) { const uint16_t *end; #ifdef HAVE_MMX @@ -2707,19 +2707,19 @@ static inline void RENAME(yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2 static inline void RENAME(rgb2rgb_init)(void){ rgb15to16 = RENAME(rgb15to16); - rgb15to24 = RENAME(rgb15to24); + rgb15tobgr24 = RENAME(rgb15tobgr24); rgb15to32 = RENAME(rgb15to32); - rgb16to24 = RENAME(rgb16to24); + rgb16tobgr24 = RENAME(rgb16tobgr24); rgb16to32 = RENAME(rgb16to32); rgb16to15 = RENAME(rgb16to15); - rgb24to16 = RENAME(rgb24to16); - rgb24to15 = RENAME(rgb24to15); - rgb24to32 = RENAME(rgb24to32); + rgb24tobgr16 = RENAME(rgb24tobgr16); + rgb24tobgr15 = RENAME(rgb24tobgr15); + rgb24tobgr32 = RENAME(rgb24tobgr32); rgb32to16 = RENAME(rgb32to16); rgb32to15 = RENAME(rgb32to15); - rgb32to24 = RENAME(rgb32to24); - rgb24tobgr15 = RENAME(rgb24tobgr15); - rgb24tobgr16 = RENAME(rgb24tobgr16); + rgb32tobgr24 = RENAME(rgb32tobgr24); + rgb24to15 = RENAME(rgb24to15); + rgb24to16 = RENAME(rgb24to16); rgb24tobgr24 = RENAME(rgb24tobgr24); rgb32tobgr32 = RENAME(rgb32tobgr32); rgb32tobgr16 = RENAME(rgb32tobgr16); From a56ed81a5c20c262a7f7675e2fdf38a633364bc5 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 19:49:13 +0000 Subject: [PATCH 05/59] Fix 4 of the unscaled rgb15/16 converters, each of these contained 2-3 bugs each of which made it fail completely, this code clearly has never been tested and been written by somone who knows the difference between a potato and a computer is that the first is round. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27519 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/rgb2rgb.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index 6f935e997a..e3ac5a6ace 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -416,13 +416,8 @@ void rgb16tobgr16(const uint8_t *src, uint8_t *dst, long src_size) for (i=0; i>5; - b = (rgb&0xF800)>>11; - dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); + unsigned rgb = ((const uint16_t*)src)[i]; + ((uint16_t*)dst)[i] = (rgb>>11) | (rgb&0x7E0) | (rgb<<11); } } @@ -433,13 +428,8 @@ void rgb16tobgr15(const uint8_t *src, uint8_t *dst, long src_size) for (i=0; i>5; - b = (rgb&0xF800)>>11; - dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); + unsigned rgb = ((const uint16_t*)src)[i]; + ((uint16_t*)dst)[i] = (rgb>>11) | ((rgb&0x7C0)>>1) | ((rgb&0x1F)<<10); } } @@ -490,13 +480,8 @@ void rgb15tobgr16(const uint8_t *src, uint8_t *dst, long src_size) for (i=0; i>5; - b = (rgb&0x7C00)>>10; - dst[2*i] = (b&0x1F) | ((g&0x3F)<<5) | ((r&0x1F)<<11); + unsigned rgb = ((const uint16_t*)src)[i]; + ((uint16_t*)dst)[i] = ((rgb&0x7C00)>>10) | ((rgb&0x3E0)<<1) | (rgb<<11); } } @@ -507,13 +492,10 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, long src_size) for (i=0; i>5; - b = (rgb&0x7C00)>>10; - dst[2*i] = (b&0x1F) | ((g&0x1F)<<5) | ((r&0x1F)<<10); + unsigned br; + unsigned rgb = ((const uint16_t*)src)[i]; + br = rgb&0x7c1F; + ((uint16_t*)dst)[i] = (br>>10) | (rgb&0x3E0) | (br<<10); } } From a42e4e1bd5affda02c1ac9ad1e6bdb4e59bd8522 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 20:16:41 +0000 Subject: [PATCH 06/59] Remove workaround for rgb/bgr mess. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27520 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index a20b26ef5a..a14e85cf30 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -221,7 +221,7 @@ const char *sws_format_name(int format); || (x)==PIX_FMT_GRAY16LE \ ) #define isRGB(x) ( \ - (x)==PIX_FMT_BGR32 \ + (x)==PIX_FMT_RGB32 \ || (x)==PIX_FMT_RGB24 \ || (x)==PIX_FMT_RGB565 \ || (x)==PIX_FMT_RGB555 \ @@ -231,7 +231,7 @@ const char *sws_format_name(int format); || (x)==PIX_FMT_MONOBLACK \ ) #define isBGR(x) ( \ - (x)==PIX_FMT_RGB32 \ + (x)==PIX_FMT_BGR32 \ || (x)==PIX_FMT_BGR24 \ || (x)==PIX_FMT_BGR565 \ || (x)==PIX_FMT_BGR555 \ From 1a636fc7f9b9e0ba5acf13859849ee27c17438b5 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 20:46:36 +0000 Subject: [PATCH 07/59] Fix 4 and 8 bit RGB/BGR input. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27521 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 891f79ac28..7be684ba88 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2507,6 +2507,12 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int i; uint8_t* src2[4]= {src[0], src[1], src[2]}; uint32_t pal[256]; + int use_pal= c->srcFormat == PIX_FMT_PAL8 + || c->srcFormat == PIX_FMT_BGR4_BYTE + || c->srcFormat == PIX_FMT_RGB4_BYTE + || c->srcFormat == PIX_FMT_BGR8 + || c->srcFormat == PIX_FMT_RGB8; + if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0; @@ -2515,15 +2521,34 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } - if (c->srcFormat == PIX_FMT_PAL8){ + if (use_pal){ for (i=0; i<256; i++){ - int p= ((uint32_t*)(src[1]))[i]; - int r= (p>>16)&0xFF; - int g= (p>> 8)&0xFF; - int b= p &0xFF; - int y= av_clip_uint8(((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16 ); - int u= av_clip_uint8(((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128); - int v= av_clip_uint8(((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128); + int p, r, g, b,y,u,v; + if(c->srcFormat == PIX_FMT_PAL8){ + p=((uint32_t*)(src[1]))[i]; + r= (p>>16)&0xFF; + g= (p>> 8)&0xFF; + b= p &0xFF; + }else if(c->srcFormat == PIX_FMT_RGB8){ + r= (i>>5 )*36; + g= ((i>>2)&7)*36; + b= (i&3 )*85; + }else if(c->srcFormat == PIX_FMT_BGR8){ + b= (i>>6 )*85; + g= ((i>>3)&7)*36; + r= (i&7 )*36; + }else if(c->srcFormat == PIX_FMT_RGB4_BYTE){ + r= (i>>3 )*255; + g= ((i>>1)&3)*85; + b= (i&1 )*255; + }else if(c->srcFormat == PIX_FMT_BGR4_BYTE){ + b= (i>>3 )*255; + g= ((i>>1)&3)*85; + r= (i&1 )*255; + } + y= av_clip_uint8(((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16 ); + u= av_clip_uint8(((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128); + v= av_clip_uint8(((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128); pal[i]= y + (u<<8) + (v<<16); } src2[1]= (uint8_t*)pal; @@ -2544,7 +2569,7 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]}; src2[0] += (srcSliceH-1)*srcStride[0]; - if (c->srcFormat != PIX_FMT_PAL8) + if (!use_pal) src2[1] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1]; src2[2] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2]; From 172a4bfaea255b29e718a9764e7bf5180d58f77c Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 21:59:15 +0000 Subject: [PATCH 08/59] Support PIX_FMT_RGB32_1 and PIX_FMT_BGR32_1. Fixes issue248. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27522 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 19 +++++++++++++++---- libswscale/swscale_internal.h | 8 ++++++++ libswscale/swscale_template.c | 22 ++++++++++++++++++++++ libswscale/yuv2rgb.c | 12 ++++++++---- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7be684ba88..7b96298781 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -22,7 +22,7 @@ */ /* - supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8/Y800, YVU9/IF09, PAL8 + supported Input formats: YV12, I420/IYUV, YUY2, UYVY, BGR32, BGR32_1, BGR24, BGR16, BGR15, RGB32, RGB32_1, RGB24, Y8/Y800, YVU9/IF09, PAL8 supported output formats: YV12, I420/IYUV, YUY2, UYVY, {BGR,RGB}{1,4,8,15,16,24,32}, Y8/Y800, YVU9/IF09 {BGR,RGB}{1,4,8,15,16} support dithering @@ -104,10 +104,12 @@ unsigned swscale_version(void) || (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_UYVY422 \ || (x)==PIX_FMT_RGB32 \ + || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_BGR24 \ || (x)==PIX_FMT_BGR565 \ || (x)==PIX_FMT_BGR555 \ || (x)==PIX_FMT_BGR32 \ + || (x)==PIX_FMT_BGR32_1 \ || (x)==PIX_FMT_RGB24 \ || (x)==PIX_FMT_RGB565 \ || (x)==PIX_FMT_RGB555 \ @@ -498,6 +500,8 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil {\ case PIX_FMT_RGB32:\ case PIX_FMT_BGR32:\ + case PIX_FMT_RGB32_1:\ + case PIX_FMT_BGR32_1:\ func(uint32_t)\ ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\ ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\ @@ -680,6 +684,8 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l { case PIX_FMT_BGR32: case PIX_FMT_RGB32: + case PIX_FMT_BGR32_1: + case PIX_FMT_RGB32_1: YSCALE_YUV_2_RGBX_C(uint32_t) ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1]; ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2]; @@ -1573,7 +1579,7 @@ static int PlanarToUyvyWrapper(SwsContext *c, uint8_t* src[], int srcStride[], i return srcSliceH; } -/* {RGB,BGR}{15,16,24,32} -> {RGB,BGR}{15,16,24,32} */ +/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ const int srcFormat= c->srcFormat; @@ -1632,12 +1638,15 @@ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int sr if(conv) { + uint8_t *srcPtr= src[0]; + if(srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1) + srcPtr += ALT32_CORR; + if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0) - conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]); + conv(srcPtr, dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]); else { int i; - uint8_t *srcPtr= src[0]; uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY; for (i=0; iswScale= rgb2rgbWrapper; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index a14e85cf30..2efaa23bf5 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -34,6 +34,12 @@ #define VOFW 2048 #define VOF (VOFW*2) +#ifdef WORDS_BIGENDIAN +#define ALT32_CORR (-1) +#else +#define ALT32_CORR 1 +#endif + typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); @@ -222,6 +228,7 @@ const char *sws_format_name(int format); ) #define isRGB(x) ( \ (x)==PIX_FMT_RGB32 \ + || (x)==PIX_FMT_RGB32_1 \ || (x)==PIX_FMT_RGB24 \ || (x)==PIX_FMT_RGB565 \ || (x)==PIX_FMT_RGB555 \ @@ -232,6 +239,7 @@ const char *sws_format_name(int format); ) #define isBGR(x) ( \ (x)==PIX_FMT_BGR32 \ + || (x)==PIX_FMT_BGR32_1 \ || (x)==PIX_FMT_BGR24 \ || (x)==PIX_FMT_BGR565 \ || (x)==PIX_FMT_BGR555 \ diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index fdb14fb0a1..888428cb73 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -2522,6 +2522,11 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i RENAME(bgr32ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } + else if (srcFormat==PIX_FMT_RGB32_1) + { + RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW); + src= formatConvBuffer; + } else if (srcFormat==PIX_FMT_BGR24) { RENAME(bgr24ToY)(formatConvBuffer, src, srcW); @@ -2542,6 +2547,11 @@ static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, i RENAME(rgb32ToY)(formatConvBuffer, src, srcW); src= formatConvBuffer; } + else if (srcFormat==PIX_FMT_BGR32_1) + { + RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW); + src= formatConvBuffer; + } else if (srcFormat==PIX_FMT_RGB24) { RENAME(rgb24ToY)(formatConvBuffer, src, srcW); @@ -2727,6 +2737,12 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } + else if (srcFormat==PIX_FMT_RGB32_1) + { + RENAME(bgr32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+VOFW; + } else if (srcFormat==PIX_FMT_BGR24) { RENAME(bgr24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); @@ -2751,6 +2767,12 @@ inline static void RENAME(hcscale)(uint16_t *dst, long dstWidth, uint8_t *src1, src1= formatConvBuffer; src2= formatConvBuffer+VOFW; } + else if (srcFormat==PIX_FMT_BGR32_1) + { + RENAME(rgb32ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1+ALT32_CORR, src2+ALT32_CORR, srcW); + src1= formatConvBuffer; + src2= formatConvBuffer+VOFW; + } else if (srcFormat==PIX_FMT_RGB24) { RENAME(rgb24ToUV)(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW); diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index c177cba0c1..5aa42c046c 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -644,6 +644,8 @@ SwsFunc yuv2rgb_get_func_ptr (SwsContext *c) av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n"); switch(c->dstFormat){ + case PIX_FMT_BGR32_1: + case PIX_FMT_RGB32_1: case PIX_FMT_BGR32: case PIX_FMT_RGB32: return yuv2rgb_c_32; case PIX_FMT_RGB24: return yuv2rgb_c_24_rgb; @@ -676,6 +678,7 @@ static int div_round (int dividend, int divisor) int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation) { const int isRgb = c->dstFormat==PIX_FMT_RGB32 + || c->dstFormat==PIX_FMT_RGB32_1 || c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB565 || c->dstFormat==PIX_FMT_RGB555 @@ -684,7 +687,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, || c->dstFormat==PIX_FMT_RGB4_BYTE || c->dstFormat==PIX_FMT_MONOBLACK; const int bpp = fmt_depth(c->dstFormat); - int i; + int i, base; uint8_t table_Y[1024]; uint32_t *table_32 = 0; uint16_t *table_16 = 0; @@ -733,6 +736,7 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, switch (bpp) { case 32: table_start= table_32 = av_malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); + base= (c->dstFormat == PIX_FMT_RGB32_1 || c->dstFormat == PIX_FMT_BGR32_1) ? 8 : 0; entry_size = sizeof (uint32_t); table_r = table_32 + 197; @@ -740,11 +744,11 @@ int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, table_g = table_32 + 197 + 2*682; for (i = -197; i < 256+197; i++) - ((uint32_t *)table_r)[i] = table_Y[i+384] << (isRgb ? 16 : 0); + ((uint32_t *)table_r)[i] = table_Y[i+384] << ((isRgb ? 16 : 0) + base); for (i = -132; i < 256+132; i++) - ((uint32_t *)table_g)[i] = table_Y[i+384] << 8; + ((uint32_t *)table_g)[i] = table_Y[i+384] << (8 + base); for (i = -232; i < 256+232; i++) - ((uint32_t *)table_b)[i] = table_Y[i+384] << (isRgb ? 0 : 16); + ((uint32_t *)table_b)[i] = table_Y[i+384] << ((isRgb ? 0 : 16) + base); break; case 24: From c1fa10dc7ec74c38354ec40b8c7984edd6510b59 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 22:31:22 +0000 Subject: [PATCH 09/59] Fix SWS_FAST_BILINEAR and SWS_POINT with some unscaled rgb<->bgr converters. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27523 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7b96298781..2c439d2f41 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2161,17 +2161,11 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH && srcFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_MONOBLACK && dstFormat != PIX_FMT_RGB32_1 && dstFormat != PIX_FMT_BGR32_1 - && !needsDither) + && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)))) c->swScale= rgb2rgbWrapper; /* LQ converters if -sws 0 or -sws 4*/ if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)){ - /* rgb/bgr -> rgb/bgr (dither needed forms) */ - if ( (isBGR(srcFormat) || isRGB(srcFormat)) - && (isBGR(dstFormat) || isRGB(dstFormat)) - && needsDither) - c->swScale= rgb2rgbWrapper; - /* yv12_to_yuy2 */ if (srcFormat == PIX_FMT_YUV420P && (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)) From a0d85f93014e97078cb398d241cb4dca0973d24e Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 4 Sep 2008 22:58:16 +0000 Subject: [PATCH 10/59] Make 16bit grayscale output work. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27524 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 71 ++++++++++++++++++++++++++++++++++- libswscale/swscale_template.c | 10 ++--- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2c439d2f41..e5c9b898a7 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -444,6 +444,31 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil else if (V<0) V=0; \ } +#define YSCALE_YUV_2_GRAY16_C(type) \ + for (i=0; i<(dstW>>1); i++){\ + int j;\ + int Y1 = 1<<18;\ + int Y2 = 1<<18;\ + int U = 1<<18;\ + int V = 1<<18;\ + type av_unused *r, *b, *g;\ + const int i2= 2*i;\ + \ + for (j=0; j>=11;\ + Y2>>=11;\ + if ((Y1|Y2|U|V)&65536)\ + {\ + if (Y1>65535) Y1=65535; \ + else if (Y1<0)Y1=0; \ + if (Y2>65535) Y2=65535; \ + else if (Y2<0)Y2=0; \ + } + #define YSCALE_YUV_2_RGBX_C(type) \ YSCALE_YUV_2_PACKEDX_C(type) \ r = (type *)c->table_rV[V]; \ @@ -458,6 +483,12 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil int U= (uvbuf0[i ]*uvalpha1+uvbuf1[i ]*uvalpha)>>19; \ int V= (uvbuf0[i+VOFW]*uvalpha1+uvbuf1[i+VOFW]*uvalpha)>>19; \ +#define YSCALE_YUV_2_GRAY16_2_C \ + for (i=0; i<(dstW>>1); i++){ \ + const int i2= 2*i; \ + int Y1= (buf0[i2 ]*yalpha1+buf1[i2 ]*yalpha)>>11; \ + int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>11; \ + #define YSCALE_YUV_2_RGB2_C(type) \ YSCALE_YUV_2_PACKED2_C\ type *r, *b, *g;\ @@ -473,6 +504,12 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil int U= (uvbuf1[i ])>>7;\ int V= (uvbuf1[i+VOFW])>>7;\ +#define YSCALE_YUV_2_GRAY16_1_C \ + for (i=0; i<(dstW>>1); i++){\ + const int i2= 2*i;\ + int Y1= buf0[i2 ]<<1;\ + int Y2= buf0[i2+1]<<1;\ + #define YSCALE_YUV_2_RGB1_C(type) \ YSCALE_YUV_2_PACKED1_C\ type *r, *b, *g;\ @@ -495,7 +532,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil g = (type *)(c->table_gU[U] + c->table_gV[V]);\ b = (type *)c->table_bU[U];\ -#define YSCALE_YUV_2_ANYRGB_C(func, func2)\ +#define YSCALE_YUV_2_ANYRGB_C(func, func2, func_g16)\ switch(c->dstFormat)\ {\ case PIX_FMT_RGB32:\ @@ -672,6 +709,22 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil ((uint8_t*)dest)[2*i2+3]= Y2;\ } \ break;\ + case PIX_FMT_GRAY16BE:\ + func_g16\ + ((uint8_t*)dest)[2*i2+0]= Y1>>8;\ + ((uint8_t*)dest)[2*i2+1]= Y1;\ + ((uint8_t*)dest)[2*i2+2]= Y2>>8;\ + ((uint8_t*)dest)[2*i2+3]= Y2;\ + } \ + break;\ + case PIX_FMT_GRAY16LE:\ + func_g16\ + ((uint8_t*)dest)[2*i2+0]= Y1;\ + ((uint8_t*)dest)[2*i2+1]= Y1>>8;\ + ((uint8_t*)dest)[2*i2+2]= Y2;\ + ((uint8_t*)dest)[2*i2+3]= Y2>>8;\ + } \ + break;\ }\ @@ -825,6 +878,22 @@ static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **l ((uint8_t*)dest)[2*i2+3]= Y2; } break; + case PIX_FMT_GRAY16BE: + YSCALE_YUV_2_GRAY16_C(void) + ((uint8_t*)dest)[2*i2+0]= Y1>>8; + ((uint8_t*)dest)[2*i2+1]= Y1; + ((uint8_t*)dest)[2*i2+2]= Y2>>8; + ((uint8_t*)dest)[2*i2+3]= Y2; + } + break; + case PIX_FMT_GRAY16LE: + YSCALE_YUV_2_GRAY16_C(void) + ((uint8_t*)dest)[2*i2+0]= Y1; + ((uint8_t*)dest)[2*i2+1]= Y1>>8; + ((uint8_t*)dest)[2*i2+2]= Y2; + ((uint8_t*)dest)[2*i2+3]= Y2>>8; + } + break; } } diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 888428cb73..ee38bd5646 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -1511,7 +1511,7 @@ FULL_YSCALEYUV2RGB default: break; } #endif //HAVE_MMX -YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C) +YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C, YSCALE_YUV_2_GRAY16_2_C) } /** @@ -1714,9 +1714,9 @@ static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t * #endif /* HAVE_MMX */ if (uvalpha < 2048) { - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C) + YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C, YSCALE_YUV_2_GRAY16_1_C) }else{ - YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C) + YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C, YSCALE_YUV_2_GRAY16_1_C) } } @@ -3221,7 +3221,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } - else if (isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 like + else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) //YV12 like { const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi @@ -3281,7 +3281,7 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, dest, uDest, dstW, chrDstW, dstFormat); } - else if (isPlanarYUV(dstFormat) || isGray(dstFormat)) //YV12 + else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) //YV12 { const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi From 237ae0ac8a4b62585c529defb1e20f360e8f1ed0 Mon Sep 17 00:00:00 2001 From: aurel Date: Thu, 4 Sep 2008 23:34:27 +0000 Subject: [PATCH 11/59] lavf: the subtitles display duration is stored in pkt.convergence_duration git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27525 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_lavf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 21e53465de..06370ebdc9 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -595,8 +595,8 @@ static int demux_lavf_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){ if(pkt.pts != AV_NOPTS_VALUE){ dp->pts=pkt.pts * av_q2d(priv->avfc->streams[id]->time_base); priv->last_pts= dp->pts * AV_TIME_BASE; - if(pkt.duration) - dp->endpts = dp->pts + pkt.duration * av_q2d(priv->avfc->streams[id]->time_base); + if(pkt.convergence_duration) + dp->endpts = dp->pts + pkt.convergence_duration * av_q2d(priv->avfc->streams[id]->time_base); } dp->pos=demux->filepos; dp->flags= !!(pkt.flags&PKT_FLAG_KEY); From 6e6692a4ff4a49c80b75f12fa30f9f36940b3f76 Mon Sep 17 00:00:00 2001 From: aurel Date: Thu, 4 Sep 2008 23:36:17 +0000 Subject: [PATCH 12/59] a valid ASS line contains 9 ',' before actual text git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27526 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mpcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpcommon.c b/mpcommon.c index 79af866cab..bf78b50fe8 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -145,7 +145,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) if (type == 'a') { // ssa/ass subs without libass => convert to plaintext int i; unsigned char* p = packet; - for (i=0; i < 8 && *p != '\0'; p++) + for (i=0; i < 9 && *p != '\0'; p++) if (*p == ',') i++; if (*p == '\0') /* Broken line? */ From 3178a5606aa85d993258695733fb01568790fe99 Mon Sep 17 00:00:00 2001 From: bcoudurier Date: Fri, 5 Sep 2008 00:25:39 +0000 Subject: [PATCH 13/59] enable yuv422p to uyvy converter git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27527 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/rgb2rgb.c | 3 +++ libswscale/rgb2rgb.h | 8 ++++++++ libswscale/rgb2rgb_template.c | 11 +++++++++++ libswscale/swscale.c | 26 ++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c index e3ac5a6ace..13388ac85a 100644 --- a/libswscale/rgb2rgb.c +++ b/libswscale/rgb2rgb.c @@ -65,6 +65,9 @@ void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, long width, long height, long lumStride, long chromStride, long dstStride); +void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, + long width, long height, + long lumStride, long chromStride, long dstStride); void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride); diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h index 0ec6273d8b..5d371acbc3 100644 --- a/libswscale/rgb2rgb.h +++ b/libswscale/rgb2rgb.h @@ -109,6 +109,14 @@ extern void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_ long width, long height, long lumStride, long chromStride, long dstStride); +/** + * + * width should be a multiple of 16 + */ +extern void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, + long width, long height, + long lumStride, long chromStride, long dstStride); + /** * Height should be a multiple of 2 and width should be a multiple of 2. * (If this is a problem for anyone then tell me, and I will fix it.) diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c index 2f27f70a5d..c98c080978 100644 --- a/libswscale/rgb2rgb_template.c +++ b/libswscale/rgb2rgb_template.c @@ -1755,6 +1755,16 @@ static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2); } +/** + * Width should be a multiple of 16. + */ +static inline void RENAME(yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, + long width, long height, + long lumStride, long chromStride, long dstStride) +{ + RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1); +} + /** * Width should be a multiple of 16. */ @@ -2727,6 +2737,7 @@ static inline void RENAME(rgb2rgb_init)(void){ yv12toyuy2 = RENAME(yv12toyuy2); yv12touyvy = RENAME(yv12touyvy); yuv422ptoyuy2 = RENAME(yuv422ptoyuy2); + yuv422ptouyvy = RENAME(yuv422ptouyvy); yuy2toyv12 = RENAME(yuy2toyv12); // uyvytoyv12 = RENAME(uyvytoyv12); // yvu9toyv12 = RENAME(yvu9toyv12); diff --git a/libswscale/swscale.c b/libswscale/swscale.c index e5c9b898a7..8fdd5eb0cc 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1648,6 +1648,24 @@ static int PlanarToUyvyWrapper(SwsContext *c, uint8_t* src[], int srcStride[], i return srcSliceH; } +static int YUV422PToYuy2Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; + + yuv422ptoyuy2(src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0]); + + return srcSliceH; +} + +static int YUV422PToUyvyWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; + + yuv422ptouyvy(src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0]); + + return srcSliceH; +} + /* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */ static int rgb2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ @@ -2233,6 +2251,14 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)))) c->swScale= rgb2rgbWrapper; + if (srcFormat == PIX_FMT_YUV422P) + { + if (dstFormat == PIX_FMT_YUYV422) + c->swScale= YUV422PToYuy2Wrapper; + else if (dstFormat == PIX_FMT_UYVY422) + c->swScale= YUV422PToUyvyWrapper; + } + /* LQ converters if -sws 0 or -sws 4*/ if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)){ /* yv12_to_yuy2 */ From 244d3d16221107cda2456706a0a60a33166db7e6 Mon Sep 17 00:00:00 2001 From: bcoudurier Date: Fri, 5 Sep 2008 01:44:33 +0000 Subject: [PATCH 14/59] simplify function selection code git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27528 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 8fdd5eb0cc..54e391cce6 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2262,24 +2262,22 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH /* LQ converters if -sws 0 or -sws 4*/ if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)){ /* yv12_to_yuy2 */ - if (srcFormat == PIX_FMT_YUV420P && - (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)) + if (srcFormat == PIX_FMT_YUV420P) { if (dstFormat == PIX_FMT_YUYV422) c->swScale= PlanarToYuy2Wrapper; - else + else if (dstFormat == PIX_FMT_UYVY422) c->swScale= PlanarToUyvyWrapper; } } #ifdef COMPILE_ALTIVEC if ((c->flags & SWS_CPU_CAPS_ALTIVEC) && - ((srcFormat == PIX_FMT_YUV420P && - (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)))) { + srcFormat == PIX_FMT_YUV420P) { // unscaled YV12 -> packed YUV, we want speed if (dstFormat == PIX_FMT_YUYV422) c->swScale= yv12toyuy2_unscaled_altivec; - else + else if (dstFormat == PIX_FMT_UYVY422) c->swScale= yv12touyvy_unscaled_altivec; } #endif From 79874cb4ea71182a5eaa7564d7cc16a16c3c987d Mon Sep 17 00:00:00 2001 From: aurel Date: Fri, 5 Sep 2008 14:18:05 +0000 Subject: [PATCH 15/59] demux_mkv: output correctly formated ASS packets git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27529 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_mkv.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 3e667d2534..166ee236c0 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -2566,10 +2566,42 @@ demux_mkv_read_block_lacing (uint8_t *buffer, uint64_t *size, return 0; } +static void fix_ass_packet(char **block, int64_t *size, + uint64_t block_duration, uint64_t timecode) +{ + char *line, *layer, *ptr = *block, *end = ptr+*size; + *end = 0; + for (; *ptr!=',' && ptrsubtitle_type == MATROSKA_SUBTYPE_SSA) + fix_ass_packet(&data, &size, block_duration, timecode); + sub_utf8 = 1; dp = new_demux_packet(size); - memcpy(dp->buffer, block, size); + memcpy(dp->buffer, data, size); dp->pts = timecode / 1000.0f; dp->endpts = (timecode + block_duration) / 1000.0f; ds_add_packet(demuxer->sub, dp); + if (data != block) + free(data); } // Taken from demux_real.c. Thanks to the original developpers :) From 81058d5af23507640036ffb061d3c42accd0b163 Mon Sep 17 00:00:00 2001 From: aurel Date: Fri, 5 Sep 2008 15:07:06 +0000 Subject: [PATCH 16/59] libass: add a new ass_process_data() to process demuxed subtitle packets conforming to the ASS spec git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27530 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.c | 20 ++++++++++++++++---- libass/ass.h | 8 ++++++++ mpcommon.c | 4 +--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 1ee81773b3..711d3c52af 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -717,21 +717,33 @@ static int process_text(ass_track_t* track, char* str) } /** - * \brief Process CodecPrivate section of subtitle stream + * \brief Process a chunk of subtitle stream data. * \param track track * \param data string to parse * \param size length of data - CodecPrivate section contains [Stream Info] and [V4+ Styles] ([V4 Styles] for SSA) sections -*/ -void ass_process_codec_private(ass_track_t* track, char *data, int size) +*/ +void ass_process_data(ass_track_t* track, char* data, int size) { char* str = malloc(size + 1); memcpy(str, data, size); str[size] = '\0'; + mp_msg(MSGT_ASS, MSGL_V, "event: %s\n", str); process_text(track, str); free(str); +} + +/** + * \brief Process CodecPrivate section of subtitle stream + * \param track track + * \param data string to parse + * \param size length of data + CodecPrivate section contains [Stream Info] and [V4+ Styles] ([V4 Styles] for SSA) sections +*/ +void ass_process_codec_private(ass_track_t* track, char *data, int size) +{ + ass_process_data(track, data, size); if (!track->event_format) { // probably an mkv produced by ancient mkvtoolnix diff --git a/libass/ass.h b/libass/ass.h index baa52ead0c..7eccbe9552 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -153,6 +153,14 @@ void ass_free_style(ass_track_t* track, int sid); */ void ass_free_event(ass_track_t* track, int eid); +/** + * \brief Parse a chunk of subtitle stream data. + * \param track track + * \param data string to parse + * \param size length of data + */ +void ass_process_data(ass_track_t* track, char* data, int size); + /** * \brief Parse Codec Private section of subtitle stream * \param track target track diff --git a/mpcommon.c b/mpcommon.c index bf78b50fe8..489cc5fc48 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -122,9 +122,7 @@ void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset) ass_track = sh ? sh->ass_track : NULL; if (!ass_track) continue; if (type == 'a') { // ssa/ass subs with libass - ass_process_chunk(ass_track, packet, len, - (long long)(pts*1000 + 0.5), - (long long)((endpts-pts)*1000 + 0.5)); + ass_process_data(ass_track, packet, len); } else { // plaintext subs with libass vo_sub = NULL; if (pts != MP_NOPTS_VALUE) { From 11d6f1fd2dc10547dfd127f1281974f5758877c7 Mon Sep 17 00:00:00 2001 From: aurel Date: Fri, 5 Sep 2008 22:59:01 +0000 Subject: [PATCH 17/59] libass: fix type mismatch between size parameter and the way it's used git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27531 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libass/ass.c | 2 +- libass/ass.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libass/ass.c b/libass/ass.c index 711d3c52af..8022dfc9be 100644 --- a/libass/ass.c +++ b/libass/ass.c @@ -1021,7 +1021,7 @@ ass_track_t* ass_read_memory(ass_library_t* library, char* buf, size_t bufsize, return track; } -char* read_file_recode(char* fname, char* codepage, int* size) +char* read_file_recode(char* fname, char* codepage, size_t* size) { char* buf; size_t bufsize; diff --git a/libass/ass.h b/libass/ass.h index 7eccbe9552..4bdea3a4aa 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -179,7 +179,7 @@ void ass_process_codec_private(ass_track_t* track, char *data, int size); */ void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration); -char* read_file_recode(char* fname, char* codepage, int* size); +char* read_file_recode(char* fname, char* codepage, size_t* size); /** * \brief Read subtitles from file. From 5c282f9a492ded6a230cdaab30850042855d004e Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 6 Sep 2008 18:13:44 +0000 Subject: [PATCH 18/59] Remove version information from libmpeg2 vd_info_t struct. It is available in other places and needs to be updated continuously. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27532 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_libmpeg2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c index 2847491e55..a05ca07b8b 100644 --- a/libmpcodecs/vd_libmpeg2.c +++ b/libmpcodecs/vd_libmpeg2.c @@ -11,7 +11,7 @@ static vd_info_t info = { - "MPEG 1/2 Video decoder libmpeg2-v0.4.0b", + "libmpeg2 MPEG 1/2 Video decoder", "libmpeg2", "A'rpi & Fabian Franz", "Aaron & Walken", From d5f550e257fb7c22bd4e72a852919b1ceacca196 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 6 Sep 2008 18:16:39 +0000 Subject: [PATCH 19/59] Remove outdated URL from vd_info_t struct. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27533 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vd_ffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c index e082d2a5a0..f50c5c69b6 100644 --- a/libmpcodecs/vd_ffmpeg.c +++ b/libmpcodecs/vd_ffmpeg.c @@ -19,7 +19,7 @@ static vd_info_t info = { "ffmpeg", "A'rpi", "A'rpi, Michael, Alex", - "native codecs (http://ffmpeg.sf.net/)" + "native codecs" }; LIBVD_EXTERN(ffmpeg) From 691a41a81725d46bf369eb2a9776c8009ed41012 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 6 Sep 2008 18:19:37 +0000 Subject: [PATCH 20/59] Replace casual GPL notice by proper license header. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27534 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_esd.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/libao2/ao_esd.c b/libao2/ao_esd.c index 3eb1c2a8bd..56a73ff555 100644 --- a/libao2/ao_esd.c +++ b/libao2/ao_esd.c @@ -1,10 +1,26 @@ /* - * ao_esd - EsounD audio output driver for MPlayer + * EsounD audio output driver for MPlayer * - * Juergen Keil + * copyright (c) 2002 Juergen Keil * - * This driver is distributed under the terms of the GPL + * This file is part of MPlayer. * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + /* * TODO / known problems: * - does not work well when the esd daemon has autostandby disabled * (workaround: run esd with option "-as 2" - fortunatelly this is From f2b8ab99948d428c07045d6698b792d2754b4bd4 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 6 Sep 2008 18:21:18 +0000 Subject: [PATCH 21/59] Fix incorrect FSF address in license header. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27535 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/compare.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TOOLS/compare.c b/TOOLS/compare.c index 8230fa25a9..67aa8ac1c2 100644 --- a/TOOLS/compare.c +++ b/TOOLS/compare.c @@ -14,9 +14,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include From 5e5c1feb69bd6b6869d866e09d1c6099af070a99 Mon Sep 17 00:00:00 2001 From: diego Date: Sat, 6 Sep 2008 18:39:12 +0000 Subject: [PATCH 22/59] license header cosmetics git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27536 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/dvd2divxscript.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TOOLS/dvd2divxscript.pl b/TOOLS/dvd2divxscript.pl index d2cd9c8b74..eaf55bd7e7 100755 --- a/TOOLS/dvd2divxscript.pl +++ b/TOOLS/dvd2divxscript.pl @@ -12,14 +12,14 @@ # thankx to all the mplayer developers for this really *great* piece of software # # -# This script is free software; you can redistribute it and/or +# This script is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public From 583ba8dcb7e82edf8c5d44b7ad371268812d3c93 Mon Sep 17 00:00:00 2001 From: diego Date: Sun, 7 Sep 2008 12:58:23 +0000 Subject: [PATCH 23/59] Remove encode2mpeglight, it is only an outdated stripped-down version of the tool maintained externally at http://encode2mpeg.sf.net/. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27537 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/README | 16 - TOOLS/encode2mpeglight.sh | 2000 ------------------------------------- 2 files changed, 2016 deletions(-) delete mode 100755 TOOLS/encode2mpeglight.sh diff --git a/TOOLS/README b/TOOLS/README index 7aa32bd150..4fc0968948 100644 --- a/TOOLS/README +++ b/TOOLS/README @@ -173,22 +173,6 @@ Note: You will need vcdimager/cdrecord to master/burn the resulting -encode2mpeglight.sh - -Author: Giacomo Comes - -Description: Convert anything MPlayer can play to VCD/SVCD/DVD MPEG. - -Usage: encode2mpeglight.sh -o -n [options] - For help and documentation run: - encode2mpeglight.sh -h - encode2mpeglight.sh -l - encode2mpeglight.sh -doc - -Note: This script uses only MEncode/MPlayer. Check the final log - file for informations/warnings about the encoding process. - - Tech scripts in the TOOLS dir ----------------------------- diff --git a/TOOLS/encode2mpeglight.sh b/TOOLS/encode2mpeglight.sh deleted file mode 100755 index e5b7a3018d..0000000000 --- a/TOOLS/encode2mpeglight.sh +++ /dev/null @@ -1,2000 +0,0 @@ -#!/bin/bash -# -# Version: 0.6.3 -# -# Licence: GPL -# -# 2004-05-22 Giacomo Comes -# 2006-11-06 -# -# Purpose: Convert anything MPlayer can play to AVI/VCD/SVCD/DVD MPEG -# -# encode2mpeglight.sh is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License. - -# encode2mpeglight.sh is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with encode2mpeglight.sh; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -############################################################################### -# encode2mpeglight.sh is a program that can create VCD/SVCD/DVD MPEGs -# and eventually extract VobSub subtitles from a DVD using only -# MEncoder/MPlayer. -# -# encode2mpeglight.sh is a stripped release of encode2mpeg and therefore the -# code is redundant in several places, with many variables defined and -# used for no apparent reason. This cannot be avoided easily. -# A command line like: -# encode2mpeglight.sh -# will produce almost the same results as: -# encode2mpeg -mpeg -mpegonly -# -# If you need more features like: -# - two or more audio streams, chapters, subtitles, menu -# - creation, burn and verification of the disk image -# - creation of MPEG-4 avi and subtitles for a hardware player -# and more, consider to use the full release (http://encode2mpeg.sf.net) -# -# encode2mpeglight.sh is mainly tested with the stable release of MPlayer, -# I try to make it work with SVN too, but due to the "unstable" nature of -# SVN, bugs may suddenly appear. If you find any, please report them to me. -############################################################################### - -############################################################################### -#### start -############################################################################### -export LC_ALL=POSIX -set -B +f -shopt -u xpg_echo nullglob -PROGNAME=${0##*/} -PROGFILE=$(type -p "$0") -VERSION=$(awk '$2=="Version:"{print $3;exit}' <"$PROGFILE") -BROWSER= - -############################################################################### -#### some functions -############################################################################### -OptionsText () { - echo - echo "Arguments enclosed in [ ] are optional" -} -############################################################################### -ModeText () { - echo - echo "$PROGNAME defaults to encode2mpeg's MPEG Mode, the other modes are not" - echo "available." -} -############################################################################### -usage () { - echo -e "Usage: $PROGNAME options source\nOptions:" - sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/,/#-/!d;s/)$//;s/) *#/ /;s/#-/# /;s/ *#L.$//;s/#//;p' "$PROGFILE" - ModeText - OptionsText -} -############################################################################### -shortusage () { - echo -e "\n$PROGNAME v. $VERSION Copyright (C) 2004-2006 Giacomo Comes\n" - echo "This is free software; see the source for copying conditions. There is NO" - echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE," - echo "to the extent permitted by law." - echo - echo "Usage: $PROGNAME options source" - echo "Options:" - sed -n '/^#### PARSING/,/^done/!d;/^done/q;/^[ ]*-[^)]*)/!d;s/)$//;s/) *#/ /;s/ *#L.$//;p' "$PROGFILE" - OptionsText -} -############################################################################### -mp_identify () { - mplayer -msglevel identify=6 -vo md5sum:outfile=/dev/null -ao null -nocache -frames 0 "$@" 2>/dev/null -} -############################################################################### -id_find () { - local ID=$1 - shift - mp_identify "$@" | awk -v id=$ID -F= '$1==id{t=$2}END{print t}' -} -############################################################################### -get_aspect () { - mplayer -vc -mpegpes, -vo null -ao null -nocache -frames 4 "$@" 2>/dev/null | sed '/^Movie-Aspect is/!d;s/.*Movie-Aspect is //;s/:.*//' -} -############################################################################### -mlistopt () { - mplayer -list-options 2>&1 | awk '$1=="Name"{m=1}{if(m&&$1!="Name"&&$1!=""&&$1!="Total:")print "\""$1"\""}' -} -############################################################################### -do_log () { - echo "$1" - ((LG)) && echo "$1" >>"$output".log || WARN="$WARN${WARN:+\n}$1" -} -############################################################################### -isarg () { - if [[ ${2:0:1} = - || ! $2 || $2 = help ]]; then - [[ ${2:0:1} = - ]] && echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'" - [[ ! $2 ]] && echo "**ERROR: [$PROGNAME] invalid null argument for option '$1'" - "$PROGFILE" -norc -l | sed '/^ '$1'$/,/^ -/!d' | sed '$d' - "$PROGFILE" -norc -l | sed '/^ '$1'[ |]/,/^ -/!d' | sed '$d' - exit 1 - fi - if [[ $2 = doc ]]; then - show_html ${3:+$3.html} - exit - fi -} -############################################################################### -pr_date () { - echo "[$(date '+%Y-%m-%d %H:%M:%S')]" -} -############################################################################### -pr_time () { - date '+%j %H %M %S' | awk '{print $1*86400+$2*3600+$3*60+$4}' -} -############################################################################### -get_abr () { - local INFO ABR - INFO=$(mp_identify "${MPLAYEROPT[@]}" ${dvddev:+-dvd-device "$dvddev"} "$@" | grep '^ID_') - ABR=$(echo "$INFO" | grep '^ID_AUDIO_BITRATE' | tail -1 | cut -f2 -d=) - case $(echo "$INFO" | grep '^ID_AUDIO_CODEC' | cut -f2 -d=) in - dvdpcm) abr=$((abr+ABR/1024)) ;; - *) abr=$((abr+ABR/1000)) ;; - esac -} -############################################################################### -get_pwd () { - pushd &>/dev/null "$1" - echo "$PWD/$2" - popd &>/dev/null -} -############################################################################### -show_html () { - local i LIST HTML PREFIX OPTION INSTDOCDIR SRCDOCDIR - INSTDOCDIR=${PROGFILE%/bin/$PROGNAME}/share/doc/encode2mpeg - SRCDOCDIR=${PROGFILE%/$PROGNAME}/doc - if [[ -f $INSTDOCDIR/encode2mpeg.html ]]; then - HTML=$(get_pwd "$INSTDOCDIR" encode2mpeg.html) - elif [[ -f $SRCDOCDIR/encode2mpeg.html ]]; then - HTML=$(get_pwd "$SRCDOCDIR" encode2mpeg.html) - else - HTML="http://encode2mpeg.sourceforge.net" - fi - if [[ -f $INSTDOCDIR/html/$1 ]]; then - HTML=$(get_pwd "$INSTDOCDIR/html" $1) - elif [[ -f $SRCDOCDIR/html/$1 ]]; then - HTML=$(get_pwd "$SRCDOCDIR/html" $1) - elif [[ $1 && ! -d $INSTDOCDIR/html && ! -d $SRCDOCDIR/html ]]; then - HTML="http://encode2mpeg.sourceforge.net/html/$1" - fi - LIST=(mozilla seamonkey firefox) - [[ ${HTML:0:1} = / ]] && PREFIX=file:// || PREFIX= - for ((i=0;i<${#LIST[*]};i++)); do - type ${LIST[i]} &>/dev/null && ${LIST[i]} -remote 'openURL('"$PREFIX$HTML"',new-tab)' 2>/dev/null && return - done - LIST=(mozilla firefox seamonkey opera konqueror epiphany galeon) - if [[ $BROWSER ]]; then - type "$BROWSER" &>/dev/null && LIST=("$BROWSER") || echo "++ WARN: default browser '$BROWSER' not found, using builtin browser list" - fi - for ((i=0;i<${#LIST[*]};i++)); do - if type "${LIST[i]}" &>/dev/null; then - case ${LIST[i]} in - opera) OPTION=--newpage ;; - epiphany|galeon) OPTION=--new-tab ;; - *) OPTION= ;; - esac - "${LIST[i]}" $OPTION "$HTML" & - return - fi - done -} - -############################################################################### -#### variable initialization -############################################################################### -abr=;asr=;vbr=;vfr=;videonorm=;frameformat=;output=;audioformat=;mp1=;mp2=;mp3=;ac3=;dts=;lpcm=;aac=;normalize=;volume=;multiaudio=;mpegchannels=;quiet=;resume=;blank=;encode=;ofps=;mono=;usesbr=;sbr=;clear=;keep=;frames=;avisplit=;channels=;vcustom=;acustom=;cpu=;interlaced=;mpegaspect=;intra_matrix=;inter_matrix=;fixavi=;mpeg=;crop=;audioid=;dvdaudiolang=;bframes=;firstchap=;lastchap=;dvdtrack=;addchapter=;cdi=;mpegfixaspect=;nowait=;vf=;frameres=;trick=;autocrop=;afm=;cache=;removecache=;turbo=;dvddev=;srate=;endpos=;fourcc=;menu=;menubg=;dvdtitle=;rotate=;menuvtsbg=;autosync=;telecine=;AFMT=;telesrc=;vcodec=;vrfyumnt=;burniso=;verify=;fixasync=;removedir=;MPGRES=;GOP=;TXTSUBOPT=;usespeed=;testmca=;chconf=;noodml=;pictsrc=;slideaudio=;audioonly=;norc=;rawsub=;vobsubsrc=;af=;lavf=;subrender=;harddup=;overburn= -unset encsid encsdx encsla addsub addsdx addsla savecache txtsub txtsubopts -zoom=0 -scale=1 -fast=1 -MAXSTEP=6 # burn is the default -step=$MAXSTEP -split=0 -vbitrate=16000 -mpegmbr=0 -overscan=0 -iter=0 -bakiter=0 -hispeed=0 -BGTITLE=1 -TANIM=0 -TFMT=png -TMODE=0 -TKFRM=0 -TSECS=5 -TPART=4 -TPARTSEC=15 -TFONTSIZE=1 -TFONTBG=1 -TLINES=2 -TCPR=2 -MENUERR=0 -DVDPLAY=0 -MENUOS=0 -TSETB=1 -DVDFS=1 -VTSMBG=0 -menufix=0 -cdburndevice=0,0,0 -dvdburndevice=/dev/cdrecorder -fsize=;fint=;ffrac=;fpre=;audiosize=0 -ASPECT=(1 1 4/3 16/9 2.21) -CH6LIST=(l r ls rs c lfe) -TOOL= -MPEG2ENCOPT=;YUVSCALEROPT=;YUVDENOISE=;MPLEXOPT=;VCDIMAGEROPT=;DVDAUTHOROPT=;CDRDAOOPT=;GROWISOFSOPT=;MUSICINOPT= -unset MPLAYEROPT MPLEXSTREAM MENCODEROPT -LPCMPAR= -SUBLANG= -unset SUBTEXT AUDIOTEXT CHAPTERTEXT TITLESET EXTWAV PROFILE MSRC -unset CLEAN -DEBUG=0 -LAVC= -WARN= -LOG= -LG=0 -SVN=0 -MAXFIX=20 -timelen=0 -ocrsub=0 -slidefps=1 -default_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27 -default_intra=$default_intra,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83 -default_inter=16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 -default_inter=$default_inter,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 -hires_intra=8,16,18,20,24,25,26,30,16,16,20,23,25,26,30,30,18,20,22,24,26,28,29,31,20,21,23,24,26,28,31,31,21,23,24 -hires_intra=$hires_intra,25,28,30,30,33,23,24,25,28,30,30,33,36,24,25,26,29,29,31,34,38,25,26,28,29,31,34,38,42 -hires_inter=$default_inter -kvcd_intra=8,9,12,22,26,27,29,34,9,10,14,26,27,29,34,37,12,14,18,27,29,34,37,38,22,26,27,31,36,37,38,40,26,27,29 -kvcd_intra=$kvcd_intra,36,39,38,40,48,27,29,34,37,38,40,48,58,29,34,37,38,40,48,58,69,34,37,38,40,48,58,69,79 -kvcd_inter=16,18,20,22,24,26,28,30,18,20,22,24,26,28,30,32,20,22,24,26,28,30,32,34,22,24,26,30,32,32,34,36,24,26 -kvcd_inter=$kvcd_inter,28,32,34,34,36,38,26,28,30,32,34,36,38,40,28,30,32,34,36,38,42,42,30,32,34,36,38,40,42,44 -tmpgenc_intra=8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27 -tmpgenc_intra=$tmpgenc_intra,29,32,35,40,48,26,27,29,32,35,40,40,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83 -tmpgenc_inter=16,17,18,19,20,21,22,23,17,18,19,20,21,22,23,24,18,19,20,21,22,23,24,25,19,20,21,22,23,24,26,27,20,21,22 -tmpgenc_inter=$tmpgenc_inter,23,25,26,27,28,21,22,23,24,26,27,28,30,22,23,24,26,27,28,30,31,23,24,25,27,28,30,31,33 -TXTSUBDEF=( languageId nolang delay 0 font arial.ttf size 28 bottom-margin 30 characterset ISO8859-1 movie-height-reduction 0 fps default ) -AVISUBDEF=( format SubViewer name-extension null fileformat unix version-number off delay 0 fps default suffix default ) - -#### encode2mpeglight.sh defauls -mpeg=1 -encode=7:2:2 - -(($#)) || ! shortusage || exit 1 -CMD=( "$@" ) - -#### options array -MOPT=( $(mlistopt | grep -v -e : -e '*') - $(mlistopt | sed -n '/:/s/:.*/"/p' | uniq) - $(mplayer -vfhelp 2>&1 | awk '/vf-/{printf("\"%s\"\n",$1)}') - $(mplayer -zrhelp 2>/dev/null | awk '$1~/^-zr/{printf("\"%s\"\n",substr($1,2))}') ) - -############################################################################### -#### check rc file -############################################################################### -if [[ -s ~/.encode2mpegrc ]]; then - for ((i=0;i<${#CMD[*]};i++)); do - [[ ${CMD[i]} = -norc ]] && norc=1 && break - done - if [[ ! $norc ]] && ! awk '{if($1~"^#")exit 1}' ~/.encode2mpegrc ; then - do_log "++ WARN: [$PROGNAME] ~/.encode2mpegrc appears to contain comments, ignoring it" >/dev/null - norc=1 - fi - [[ ! $norc ]] && set -- $(<~/.encode2mpegrc) "$@" -fi - -############################################################################### -#### arguments parsing -############################################################################### -while (($#)) ; do -#### PARSING - case $1 in - -h|-help) - #-list the available options - [[ $2 = doc || $2 = help ]] && isarg $1 $2 - shortusage - exit - ;; - -l|-longhelp) - #-print this help page - [[ $2 = doc || $2 = help ]] && isarg $1 $2 - usage - exit - ;; - -doc|-documentation) #[[:][]] - #-show the html documentation - [[ $2 = doc || $2 = help ]] && isarg $1 $2 - [[ ${2%:*} != $2 ]] && BROWSER=${2%:*} - show_html ${2#*:} - exit - ;; - -noshowlog) - #-do not show the log file - [[ $2 = doc || $2 = help ]] && isarg $1 $2 - quiet=1 - ;; - -o|-output) # - #-filename of the output stream - echo "$2" | grep -q '/' && [[ ! -d ${2%/*} ]] && echo "**ERROR: [$PROGNAME] directory ${2%/*} argument of '$1' not found" && exit 1 - output=$2 - shift - ;; - -a) # - # aspect ratio VCD SVCD DVD - # 1 - 1:1 x * x x = mpeg2enc and mencoder - # 2 - 4:3 x x x * = mencoder only - # 3 - 16:9 x x x - #- 4 - 2.21:1 * x - MPEG2ENCOPT="$MPEG2ENCOPT -a $2" - [[ $2 -eq 0 ]] && MPEG2ENCOPT="${MPEG2ENCOPT% ${2}} 1" - mpegaspect=$2 - isarg $1 "$2" direct - shift - ;; - -mpegfixaspect) #[pad|crop] - # force the aspect ratio of the source video to match the one - # specified with -a; this can be done padding the video with - #-black lines or cropping the video; the default is padding - [[ $2 = doc || $2 = help ]] && isarg $1 $2 aspect - mpegfixaspect=0 - if [[ $2 = pad || $2 = crop ]]; then - [[ $2 = crop ]] && mpegfixaspect=1 - shift - fi - ;; - -rotate) #<0-3> - # rotate the source video by 90 degrees; set -mpegfixaspect; - # 0 rotate clockwise and flip, 1 rotate clockwise - #-2 rotate counterclockwise, 3 rotate counterclockwise and flip - rotate=1 - echo "$2" | grep -q '^[0-3]$' && rotate=$2 - isarg $1 "$2" aspect - shift - : ${mpegfixaspect:=0} - ;; - -overscan) # - # shrink the video of n% and surround it with black borders, - # n can be 1-99, using 10 should make visible on a TV the full video - # image; if n is negative, the result is a magnification of the - # central part of the image; n>0 set -mpegfixaspect pad, n<0 set - #--mpegfixaspect crop; in Avi Mode n can only be positive - echo "$2" | grep -qE '^-?[0-9]?[0-9]$' && overscan=$2 - [[ ${2:0:1} = - ]] && mpegfixaspect=1 || mpegfixaspect=0 - isarg $1 "${2#-}" $( ((step==1)) && echo Avi || echo aspect) - shift - ;; - -abr) # - #-audio bit rate of the VCD/SVCD/DVD [MP2:224,MP3:128,AC3:448] - if [[ $2 = list ]]; then - sed '/^check_abr/,/case/!d;/'"$audioformat"':/!d;/[^0-9]'"$asr"'/!d;s/[^)]*)//;s/ */ /g;s/^/'"$audioformat $asr"'/' "$PROGFILE" - exit - fi - abr=$2 - isarg $1 "$2" direct - shift - ;; - -asr) # - #-audio sample rate of the VCD/SVCD/DVD [MP2/MP3:44100,AC3:48000] - asr=$2 - isarg $1 "$2" direct - shift - ;; - -vbr) # - #-video bit rate of the VCD/SVCD/DVD [VCD:1152,SVCD:2500,DVD:7500] - vbr=$2 - isarg $1 "$2" direct - shift - ;; - -vfr) # - # video frame rate of the output stream - # [NTSC/VCD:4,NTSC/SVCD-DVD:1,PAL:3,AVI:2] - # 1 - 24000.0/1001.0 (NTSC 3:2 pulldown converted FILM) - # 2 - 24.0 (NATIVE FILM) - # 3 - 25.0 (PAL/SECAM VIDEO / converted FILM) - # 4 - 30000.0/1001.0 (NTSC VIDEO) - # 5 - 30.0 - # 6 - 50.0 (PAL FIELD RATE) - # 7 - 60000.0/1001.0 (NTSC FIELD RATE) - #- 8 - 60.0 - vfr=$2 - isarg $1 "$2" direct - shift - ;; - -n|-video-norm) # - # set the video norm of the VCD/SVCD/DVD; NTSC is USA standard, - # PAL is European standard and SECAM is French standard; concerning - #-VCD/SVCD/DVD encoding, SECAM is equivalent to PAL - case $2 in - n|N|ntsc|NTSC) videonorm=n ;; - p|P|pal|PAL) videonorm=p ;; - s|S|secam|SECAM) videonorm=s ;; - doc|help) isarg $1 $2 direct ;; - *) echo "**ERROR: [$PROGNAME] invalid argument '$2' for option '$1'" ; "$PROGFILE" -norc $1 help ; exit 1 ;; - esac - shift - ;; - -p|-pulldown|-telecine) # - # set a flag in the output stream of the SVCD/DVD that tell the - # decoder to play the movie as NTSC video using "3:2 pull-down" - #-instead of "-vfr 4" use "-vfr 1 -p" (smaller output stream) - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - telecine=1 - ;; - -res) #<1-7> - # force one of the following video resolutios: - # PAL NTSC - # 1 352x288 352x240 (VCD) - # 2 352x576 352x480 (CVD) - # 3 480x576 480x480 (SVCD) - # 4 528x576 528x480 (KVCD) - # 5 544x576 544x480 (KVCD) - # 6 704x576 704x480 (DVB) - #- 7 720x576 720x480 (DVD) - isarg $1 "$2" direct - echo "$2" | grep -q '^[1-7]$' && MPGRES=$2 - shift - ;; - -gop) # - # set the number of pictures per GOP; the default value is the one - #-required by the standard - isarg $1 "$2" direct - GOP=$2 - shift - ;; - -kvcd) #<1-4> - # generate KVCD (www.kvcd.net) compliant frames on output; the - # following resolutions are possible: - # PAL NTSC GOP - # 1 528x576 528x480 24 - # 2 528x576 528x480 def - # 3 544x576 544x480 24 - #- 4 544x576 544x480 def - isarg $1 "$2" direct - a=1 - echo "$2" | grep -q '^[1-4]$' && a=$2 - shift 2 - set -- " " -qmatrix kvcd -res $((3+(a+1)/2)) $([[ $a = [13] ]] && echo "-gop 24") "$@" - ;; - -vcd) # - #-generate VCD compliant frames on output (default) - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - frameformat=VCD - ;; - -svcd) #[1-2] - # generate SVCD compliant frames on output; the following resolutions - # are possible: PAL NTSC - # 1 480x576 480x480 - # 2 352x288 352x240 - #-default is 1 - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - frameformat=SVCD - frameres=1 - echo "$2" | grep -q '^[1-2]$' && frameres=$2 && shift - ;; - -svcdht) # - # enable the VCD header trick; this trick could allow to play SVCD on - # DVD player that does not support SVCD. For more details see: - #-http://www.videohelp.com/svcd - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - trick=1 - ;; - -dvd) #[1-5] - # generate DVD compliant frames on output; the following resolutions - # are possible: PAL NTSC - # 1 720x576 720x480 - # 2 704x576 704x480 - # 3 480x576 480x480 (non standard DVD-SVCD) - # 4 352x576 352x480 - # 5 352x288 352x240 - #-default is 1 - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - frameformat=DVD - frameres=1 - echo "$2" | grep -q '^[1-5]$' && frameres=$2 && shift - ;; - -vcodec) # - #-force the selected video codec [VCD:mpeg1,SVCD-DVD:mpeg2,AVI:mpeg4] - isarg $1 "$2" Avi - [[ $2 = mpeg[124] ]] && vcodec=$2 && [[ ${vcodec:4:1} = [12] ]] && vcodec=${vcodec}video - shift - ;; - -qmatrix) # - # mpeg2enc custom quantization matrices: kvcd produce a smaller - #-output stream, hi-res is good for hi-quality source material - case $2 in - kvcd|tmpgenc|default|hi-res) - MPEG2ENCOPT="$MPEG2ENCOPT -K $2" - intra_matrix=$(eval echo \$${2/-}_intra) - inter_matrix=$(eval echo \$${2/-}_inter) - ;; - *) - MPEG2ENCOPT="$MPEG2ENCOPT -K default" - intra_matrix= - inter_matrix= - ;; - esac - isarg $1 "$2" direct - shift - ;; - -mpeg1vbr) # - # produce a VCD/MPEG-1 variable bit rate stream, the output stream - # is smaller and a complete movie could fit in one VCD; check if - #-your hardware player support variable bit rate VCD - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - MPEG2ENCOPT="$MPEG2ENCOPT -q 8" - LAVC=":vrc_buf_size=327" - ;; - -mpegmbr) # - # set the maximum video bit rate; the default is the value of vbr; - #-a value of 0 remove the limit - mpegmbr=$2 - [[ $2 -eq 0 ]] && mpegmbr= - isarg $1 "$2" mpeg - shift - ;; - -mpegchannels) #<1-6> - # number of channels of the MPEG audio stream, 1-6 for ac3 and lpcm; - # 1-2 for mp1, mp2 and mp3; 3-6 for mp2 Multichannel Audio; for the - #-avi audio stream use MPlayer's option -channels - mpegchannels=2 - isarg $1 "$2" direct - echo "$2" | grep -q '^[1-6]$' && mpegchannels=$2 - shift - ;; - -normalize) - #-normalize to the audio stream(s) - [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $encode ]] && echo Avi || echo direct) - normalize=1 - ;; - -volume) # - # change amplitude of the audio stream; less than 1.0 decreases, - #-greater than 1.0 increases (float) - volume=$2 - isarg $1 "$2" direct - shift - ;; - -noscale) # - # encode2mpeg automatically scales the video according to the MPEG - # profile chosen, this option disables this feature; used mainly - # for debug purposes. - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - scale= - ;; - -monochrome) - #-create B/W video or avoid color artifacts in B/W source streams - [[ $2 = doc || $2 = help ]] && isarg $1 $2 direct - YUVSCALEROPT="$YUVSCALEROPT -O MONOCHROME" - ;; - -split) # - #-split the resulting MPEG stream in MB chunks. - split=$2 - isarg $1 "$2" direct - shift - ;; - -encode) # - # the parameter n:m:i selects the audio codec, video codec options - # and number of pass for mencoder, possible values are: - # n m i - # 0 copy 0 copy 1 - # 1 pcm 1 libavcodec/mpeg 2 - # 2 mp3lame/fast 2 as 1 + mbd=2 3 - # 3 mp3lame/standard 3 as 1 + compression opts - # 4 libavcodec/mp2 4 as 1 + quality opts - # 5 libavcodec/mp3 - # 6 libavcodec/ac3 for m=[2-4] and i>1 turbo is on - # 7 toolame/mp2 - # 8 libfaac/aac - #- with n=[3-7] b specify the audio bit rate - encode=5:3:2 - echo "$2" | grep -qE '^[0-8]:[0-4]:[1-9](,[0-9]+)?$' && encode=$2 - isarg $1 "$2" $([[ $mpeg ]] && echo mpeg || echo Avi) - shift - ;; - -telecinesrc) # - # if you use -encode n:0:i in MPEG Mode, encode2mpeg needs to know - # if the source NTSC MPEG is telecined, otherwise the stream copy may - # not work properly; normally encode2mpeg is able to detect telecined - # sources, but, if the source MPEG is mixed, part not telecined and - # part telecined, encode2mpeg may fail to detect it. In such case, - #-you can use this option to specify a telecined source. - [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg - telesrc=1 - ;; - -turbo) #<0-1> - # disable (0) or force (1) turbo mode for the first pass of N pass - #-encoding (N>1) - echo "$2" | grep -q '^[0-1]$' && turbo=$2 - isarg $1 "$2" Avi - shift - ;; - -hispeed) # - # increase the encoding speed of 25-50% (with -encode n:1:1); the - # output video stream will be bigger and can have poor quality; this - # option is mainly intented for testing, but it can be used if you - #-want to create more quickly an MPEG-4/AVI or a DVD. - [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi - hispeed=1 - ;; - -bframes) #<0-4> - # specify the number of B frames; if -encode is n:3:i the default 2, - #-otherwise the default is no B frames; for VCD the default is 2 - echo "$2" | grep -q '^[0-4]$' && bframes=$2 - isarg $1 "$2" Avi - shift - ;; - -vcustom) # - # specify a custom set of video options for libavcodec, use with - #--encode n:1:i - vcustom=$2 - isarg $1 "$2" Avi - shift - ;; - -acustom) # - # specify a custom set of lame options (with -encode 2:m:i) or faac - #-options (with -encode 8:m:i) - acustom=$2 - isarg $1 "$2" Avi - shift - ;; - -encsid) # - #-dump the DVD vobsub, sid is the number you give the -sid option - # of MPlayer. - encsid=( ${2//,/ } ) - isarg $1 "$2" subtitle - shift - ;; - -encsdx) # - # if you dump subtitle 2 and 4 and you want them to have id 0 and 1 - #-use -encsid 2,4 -encsdx 0,1 - encsdx=( ${2//,/ } ) - isarg $1 "$2" subtitle - shift - ;; - -encsla) # - #-see doc/html/subtitle.html - encsla=( ${2//,/ } ) - isarg $1 "$2" subtitle - shift - ;; - -usespeed) # - # do frame rate conversion changing the playback speed; this option - # can be used if you are converting from NTSC 24fps, with or without - # telecine, to PAL 25fps and viceversa; during normal frame rate - # conversion, frames are skipped or duplicated as needed; with this - #-option all the frames are encoded - [[ $2 = doc || $2 = help ]] && isarg $1 $2 mpeg - usespeed=1 - ;; - -usesbr) #[1-6|>100] - # use the suggested video bitrate to set the output stream size - # 1 - for 650MB CD 4 - for 2 x 650MB CD - # 2 - for 700MB CD (default) 5 - for 2 x 700MB CD - # 3 - for 800MB CD 6 - for 2 x 800MB CD - # n where n > 100 will set the file size to n MB - #-with -multiaudio you must to set the streamsize in MB - usesbr=2 - SBR=(650 700 800 "2 x 650" "2 x 700" "2 x 800") - echo "$2" | grep -q '^[1-6]$' && usesbr=$2 && shift - echo "$2" | grep -qE '^[1-9][0-9]{2,}$' && usesbr=$2 && shift - [[ $2 = doc || $2 = help ]] && isarg $1 $2 Avi - ;; - -cpu) # - #-number of cpu to use, default all the cpu present in the system - cpu=1 - echo "$2" | grep -q '^[1-8]$' && cpu=$2 - isarg $1 "$2" Avi - shift - ;; - -interlaced) - #-turn on optimization for interlaced source video. - [[ $2 = doc || $2 = help ]] && isarg $1 $2 $([[ $mpeg ]] && echo mpeg || echo Avi) - interlaced=1 - ;; - -slidefps) # - # fps to use when creating video from pictures, default is 1; if - # there is a audio file associated with a picture, the duration of - #-the audio file is used - isarg $1 "$2" images - slidefps=$(awk -v a=$2 'BEGIN{printf("%.3f",1/a)}') - shift - ;; - -slideaudio) #