summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2002-12-04 05:33:40 +0000
committerMike Melanson <mike@multimedia.cx>2002-12-04 05:33:40 +0000
commit1a5f74a6255d68aeabe51c9edb2d19ec0dc36274 (patch)
tree46b7d4f0718b232a4933c49b7e51517982171407
parent213efefd0b1a5a8dfa51de463ebbe12ec37eca92 (diff)
downloadxine-lib-1a5f74a6255d68aeabe51c9edb2d19ec0dc36274.tar.gz
xine-lib-1a5f74a6255d68aeabe51c9edb2d19ec0dc36274.tar.bz2
modified YUV9 -> YV12 converter
CVS patchset: 3423 CVS date: 2002/12/04 05:33:40
-rw-r--r--src/libxinevdec/yuv.c8
-rw-r--r--src/xine-utils/color.c35
-rw-r--r--src/xine-utils/xineutils.h12
3 files changed, 33 insertions, 22 deletions
diff --git a/src/libxinevdec/yuv.c b/src/libxinevdec/yuv.c
index 08c89c5dd..fcaf7ec09 100644
--- a/src/libxinevdec/yuv.c
+++ b/src/libxinevdec/yuv.c
@@ -21,7 +21,7 @@
* Actually, this decoder just reorganizes chunks of raw YUV data in such
* a way that xine can display them.
*
- * $Id: yuv.c,v 1.13 2002/12/01 07:16:53 tmmm Exp $
+ * $Id: yuv.c,v 1.14 2002/12/04 05:33:40 tmmm Exp $
*/
#include <stdio.h>
@@ -160,17 +160,21 @@ static void yuv_decode_data (video_decoder_t *this_gen,
yuv9_to_yv12(
/* Y */
this->buf,
+ this->width,
img->base[0],
img->pitches[0],
/* U */
this->buf + (this->width * this->height),
+ this->width / 4,
img->base[1],
img->pitches[1],
/* V */
this->buf + (this->width * this->height) +
(this->width * this->height / 16),
+ this->width / 4,
img->base[2],
img->pitches[2],
+ /* width x height */
this->width,
this->height);
@@ -259,8 +263,6 @@ static void yuv_dispose (video_decoder_t *this_gen) {
free (this_gen);
}
-
-
static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
yuv_decoder_t *this ;
diff --git a/src/xine-utils/color.c b/src/xine-utils/color.c
index 6d22cd124..2602250cc 100644
--- a/src/xine-utils/color.c
+++ b/src/xine-utils/color.c
@@ -61,7 +61,7 @@
* instructions), these macros will automatically map to those special
* instructions.
*
- * $Id: color.c,v 1.10 2002/12/01 07:12:41 tmmm Exp $
+ * $Id: color.c,v 1.11 2002/12/04 05:33:40 tmmm Exp $
*/
#include "xine_internal.h"
@@ -133,9 +133,9 @@ int v_b_table[256];
void (*yuv444_to_yuy2) (yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch);
void (*yuv9_to_yv12)
- (unsigned char *y_src, unsigned char *y_dest, int y_pitch,
- unsigned char *u_src, unsigned char *u_dest, int u_pitch,
- unsigned char *v_src, unsigned char *v_dest, int v_pitch,
+ (unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch,
+ unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch,
+ unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch,
int width, int height);
/*
@@ -499,20 +499,20 @@ static void vscale_chroma_line (unsigned char *dst, int pitch,
}
static void upsample_c_plane_c(unsigned char *src, int src_width,
- int src_height, unsigned char *dest, unsigned int dest_pitch) {
+ int src_height, unsigned char *dest,
+ unsigned int src_pitch, unsigned int dest_pitch) {
unsigned char *cr1;
unsigned char *cr2;
unsigned char *tmp;
int y;
- int chroma_width = (src_width + 15) & ~0xF;
cr1 = &dest[dest_pitch * (src_height * 2 - 2)];
cr2 = &dest[dest_pitch * (src_height * 2 - 3)];
/* horizontally upscale first line */
hscale_chroma_line (cr1, src, src_width);
- src += chroma_width;
+ src += src_pitch;
/* store first line */
memcpy (dest, cr1, src_width * 2);
@@ -521,7 +521,7 @@ static void upsample_c_plane_c(unsigned char *src, int src_width,
for (y = 0; y < (src_height - 1); y++) {
hscale_chroma_line (cr2, src, src_width);
- src += chroma_width;
+ src += src_pitch;
/* interpolate and store two lines */
vscale_chroma_line (dest, dest_pitch, cr1, cr2, src_width * 2);
@@ -534,7 +534,7 @@ static void upsample_c_plane_c(unsigned char *src, int src_width,
}
/* horizontally upscale and store last line */
- src -= chroma_width;
+ src -= src_pitch;
hscale_chroma_line (dest, src, src_width);
}
@@ -543,9 +543,9 @@ static void upsample_c_plane_c(unsigned char *src, int src_width,
*
*/
void yuv9_to_yv12_c
- (unsigned char *y_src, unsigned char *y_dest, int y_pitch,
- unsigned char *u_src, unsigned char *u_dest, int u_pitch,
- unsigned char *v_src, unsigned char *v_dest, int v_pitch,
+ (unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch,
+ unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch,
+ unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch,
int width, int height) {
int y;
@@ -553,15 +553,18 @@ void yuv9_to_yv12_c
/* Y plane */
for (y=0; y < height; y++) {
xine_fast_memcpy (y_dest, y_src, width);
- y_src += width;
- y_dest += y_pitch;
+ y_src += y_src_pitch;
+ y_dest += y_dest_pitch;
}
/* U plane */
- upsample_c_plane_c(u_src, width / 4, height / 4, u_dest, u_pitch);
+ upsample_c_plane_c(u_src, width / 4, height / 4, u_dest,
+ u_src_pitch, u_dest_pitch);
/* V plane */
- upsample_c_plane_c(v_src, width / 4, height / 4, v_dest, v_pitch);
+ upsample_c_plane_c(v_src, width / 4, height / 4, v_dest,
+ v_src_pitch, v_dest_pitch);
+
}
/*
diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h
index fce1b31a8..1d6561b8c 100644
--- a/src/xine-utils/xineutils.h
+++ b/src/xine-utils/xineutils.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xineutils.h,v 1.27 2002/11/11 13:45:37 miguelfreitas Exp $
+ * $Id: xineutils.h,v 1.28 2002/12/04 05:33:40 tmmm Exp $
*
*/
#ifndef XINEUTILS_H
@@ -701,8 +701,9 @@ static inline void _x_setenv(const char *name, const char *val, int _xx)
/*
* Color Conversion Utility Functions
* The following data structures and functions facilitate the conversion
- * of RGB images to packed YUV (YUY2) images. All of the meaty details
- * are written in color.c.
+ * of RGB images to packed YUV (YUY2) images. There are also functions to
+ * convert from YUV9 -> YV12. All of the meaty details are written in
+ * color.c.
*/
typedef struct yuv_planes_s {
@@ -721,6 +722,11 @@ void free_yuv_planes(yuv_planes_t *yuv_planes);
extern void (*yuv444_to_yuy2)
(yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch);
+extern void (*yuv9_to_yv12)
+ (unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch,
+ unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch,
+ unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch,
+ int width, int height);
#define SCALEFACTOR 65536
#define CENTERSAMPLE 128