Commit 11f18faf authored by Michael Niedermayer's avatar Michael Niedermayer

huffyuv

Originally committed as revision 1211 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 58445440
......@@ -16,7 +16,7 @@ OBJS= common.o utils.o mem.o allcodecs.o \
motion_est.o imgconvert.o imgresample.o msmpeg4.o \
mpeg12.o h263dec.o svq1.o rv10.o mpegaudiodec.o pcm.o simple_idct.o \
ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
wmadec.o fft.o mdct.o mace.o
wmadec.o fft.o mdct.o mace.o huffyuv.o
ASM_OBJS=
# currently using liba52 for ac3 decoding
......
......@@ -53,6 +53,7 @@ void avcodec_register_all(void)
register_avcodec(&msmpeg4v3_encoder);
register_avcodec(&wmv1_encoder);
register_avcodec(&wmv2_encoder);
register_avcodec(&huffyuv_encoder);
#endif /* CONFIG_ENCODERS */
register_avcodec(&rawvideo_codec);
......@@ -78,6 +79,7 @@ void avcodec_register_all(void)
register_avcodec(&wmav2_decoder);
register_avcodec(&mace3_decoder);
register_avcodec(&mace6_decoder);
register_avcodec(&huffyuv_decoder);
#ifdef CONFIG_AC3
register_avcodec(&ac3_decoder);
#endif
......
......@@ -5,8 +5,8 @@
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4638
#define LIBAVCODEC_BUILD_STR "4638"
#define LIBAVCODEC_BUILD 4639
#define LIBAVCODEC_BUILD_STR "4639"
enum CodecID {
CODEC_ID_NONE,
......@@ -34,6 +34,7 @@ enum CodecID {
CODEC_ID_WMAV2,
CODEC_ID_MACE3,
CODEC_ID_MACE6,
CODEC_ID_HUFFYUV,
/* various pcm "codecs" */
CODEC_ID_PCM_S16LE,
......@@ -770,6 +771,23 @@ typedef struct AVCodecContext {
* CPU features (i.e. MMX, SSE. ...)
*/
unsigned dsp_mask;
/**
* bits per sample/pixel from the demuxer (needed for huffyuv)
* encoding; set by lavc
* decoding: set by user
*/
int bits_per_sample;
/**
* prediction method (needed for huffyuv)
* encoding; set by user
* decoding: unused
*/
int prediction_method;
#define FF_PRED_LEFT 0
#define FF_PRED_PLANE 1
#define FF_PRED_MEDIAN 2
} AVCodecContext;
typedef struct AVCodec {
......@@ -810,6 +828,7 @@ extern AVCodec msmpeg4v2_encoder;
extern AVCodec msmpeg4v3_encoder;
extern AVCodec wmv1_encoder;
extern AVCodec wmv2_encoder;
extern AVCodec huffyuv_encoder;
extern AVCodec h263_decoder;
extern AVCodec mpeg4_decoder;
......@@ -831,6 +850,7 @@ extern AVCodec mp2_decoder;
extern AVCodec mp3_decoder;
extern AVCodec mace3_decoder;
extern AVCodec mace6_decoder;
extern AVCodec huffyuv_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
......
......@@ -1342,6 +1342,38 @@ static void clear_blocks_c(DCTELEM *blocks)
memset(blocks, 0, sizeof(DCTELEM)*6*64);
}
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
int i;
for(i=0; i+7<w; i++){
dst[i+0] += src[i+0];
dst[i+1] += src[i+1];
dst[i+2] += src[i+2];
dst[i+3] += src[i+3];
dst[i+4] += src[i+4];
dst[i+5] += src[i+5];
dst[i+6] += src[i+6];
dst[i+7] += src[i+7];
}
for(; i<w; i++)
dst[i+0] += src[i+0];
}
static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
int i;
for(i=0; i+7<w; i++){
dst[i+0] = src1[i+0]-src2[i+0];
dst[i+1] = src1[i+1]-src2[i+1];
dst[i+2] = src1[i+2]-src2[i+2];
dst[i+3] = src1[i+3]-src2[i+3];
dst[i+4] = src1[i+4]-src2[i+4];
dst[i+5] = src1[i+5]-src2[i+5];
dst[i+6] = src1[i+6]-src2[i+6];
dst[i+7] = src1[i+7]-src2[i+7];
}
for(; i<w; i++)
dst[i+0] = src1[i+0]-src2[i+0];
}
void dsputil_init(DSPContext* c, unsigned mask)
{
static int init_done = 0;
......@@ -1431,6 +1463,9 @@ void dsputil_init(DSPContext* c, unsigned mask)
/* dspfunc(avg_no_rnd_qpel, 1, 8); */
#undef dspfunc
c->add_bytes= add_bytes_c;
c->diff_bytes= diff_bytes_c;
#ifdef HAVE_MMX
dsputil_init_mmx(c, mask);
if (ff_bit_exact)
......
......@@ -117,6 +117,11 @@ typedef struct DSPContext {
op_pixels_abs_func pix_abs8x8_x2;
op_pixels_abs_func pix_abs8x8_y2;
op_pixels_abs_func pix_abs8x8_xy2;
/* huffyuv specific */
//FIXME note: alignment isnt guranteed currently but could be if needed
void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 16*/,int w);
} DSPContext;
void dsputil_init(DSPContext* p, unsigned mask);
......
This diff is collapsed.
......@@ -453,6 +453,51 @@ static int pix_sum16_mmx(UINT8 * pix, int line_size){
return sum;
}
static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w){
int i=0;
asm volatile(
"1: \n\t"
"movq (%1, %0), %%mm0 \n\t"
"movq (%2, %0), %%mm1 \n\t"
"paddb %%mm0, %%mm1 \n\t"
"movq %%mm1, (%2, %0) \n\t"
"movq 8(%1, %0), %%mm0 \n\t"
"movq 8(%2, %0), %%mm1 \n\t"
"paddb %%mm0, %%mm1 \n\t"
"movq %%mm1, 8(%2, %0) \n\t"
"addl $16, %0 \n\t"
"cmpl %3, %0 \n\t"
" jb 1b \n\t"
: "+r" (i)
: "r"(src), "r"(dst), "r"(w-15)
);
for(; i<w; i++)
dst[i+0] += src[i+0];
}
static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
int i=0;
asm volatile(
"1: \n\t"
"movq (%2, %0), %%mm0 \n\t"
"movq (%1, %0), %%mm1 \n\t"
"psubb %%mm0, %%mm1 \n\t"
"movq %%mm1, (%3, %0) \n\t"
"movq 8(%2, %0), %%mm0 \n\t"
"movq 8(%1, %0), %%mm1 \n\t"
"psubb %%mm0, %%mm1 \n\t"
"movq %%mm1, 8(%3, %0) \n\t"
"addl $16, %0 \n\t"
"cmpl %4, %0 \n\t"
" jb 1b \n\t"
: "+r" (i)
: "r"(src1), "r"(src2), "r"(dst), "r"(w-15)
);
for(; i<w; i++)
dst[i+0] = src1[i+0]-src2[i+0];
}
#if 0
static void just_return() { return; }
#endif
......@@ -531,6 +576,9 @@ void dsputil_init_mmx(DSPContext* c, unsigned mask)
c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_mmx;
c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_mmx;
c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
c->add_bytes= add_bytes_mmx;
c->diff_bytes= diff_bytes_mmx;
if (mm_flags & MM_MMXEXT) {
c->pix_abs16x16 = pix_abs16x16_mmx2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment