Commit 54009d42 authored by Michael Niedermayer's avatar Michael Niedermayer

remove mpegvideo.c img resample dependancy

Originally committed as revision 5258 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 6b250e47
...@@ -4056,6 +4056,11 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) ...@@ -4056,6 +4056,11 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->inner_add_yblock = ff_snow_inner_add_yblock; c->inner_add_yblock = ff_snow_inner_add_yblock;
#endif #endif
c->shrink[0]= ff_img_copy_plane;
c->shrink[1]= ff_shrink22;
c->shrink[2]= ff_shrink44;
c->shrink[3]= ff_shrink88;
c->prefetch= just_return; c->prefetch= just_return;
#ifdef HAVE_MMX #ifdef HAVE_MMX
......
...@@ -76,6 +76,12 @@ void ff_vp3_idct_c(DCTELEM *block/* align 16*/); ...@@ -76,6 +76,12 @@ void ff_vp3_idct_c(DCTELEM *block/* align 16*/);
void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/);
/* 1/2^n downscaling functions from imgconvert.c */
void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
/* minimum alignment rules ;) /* minimum alignment rules ;)
if u notice errors in the align stuff, need more alignment for some asm code for some cpu if u notice errors in the align stuff, need more alignment for some asm code for some cpu
or need to use a function with less aligned data then send a mail to the ffmpeg-dev list, ... or need to use a function with less aligned data then send a mail to the ffmpeg-dev list, ...
...@@ -345,6 +351,8 @@ typedef struct DSPContext { ...@@ -345,6 +351,8 @@ typedef struct DSPContext {
void (*inner_add_yblock)(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8); void (*inner_add_yblock)(uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8);
void (*prefetch)(void *mem, int stride, int h); void (*prefetch)(void *mem, int stride, int h);
void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
} DSPContext; } DSPContext;
void dsputil_static_init(void); void dsputil_static_init(void);
......
...@@ -572,7 +572,7 @@ int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt, ...@@ -572,7 +572,7 @@ int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
return dst_pix_fmt; return dst_pix_fmt;
} }
static void img_copy_plane(uint8_t *dst, int dst_wrap, void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
const uint8_t *src, int src_wrap, const uint8_t *src, int src_wrap,
int width, int height) int width, int height)
{ {
...@@ -612,7 +612,7 @@ void img_copy(AVPicture *dst, const AVPicture *src, ...@@ -612,7 +612,7 @@ void img_copy(AVPicture *dst, const AVPicture *src,
break; break;
} }
bwidth = (width * bits + 7) >> 3; bwidth = (width * bits + 7) >> 3;
img_copy_plane(dst->data[0], dst->linesize[0], ff_img_copy_plane(dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], src->data[0], src->linesize[0],
bwidth, height); bwidth, height);
break; break;
...@@ -626,17 +626,17 @@ void img_copy(AVPicture *dst, const AVPicture *src, ...@@ -626,17 +626,17 @@ void img_copy(AVPicture *dst, const AVPicture *src,
h >>= pf->y_chroma_shift; h >>= pf->y_chroma_shift;
} }
bwidth = (w * pf->depth + 7) >> 3; bwidth = (w * pf->depth + 7) >> 3;
img_copy_plane(dst->data[i], dst->linesize[i], ff_img_copy_plane(dst->data[i], dst->linesize[i],
src->data[i], src->linesize[i], src->data[i], src->linesize[i],
bwidth, h); bwidth, h);
} }
break; break;
case FF_PIXEL_PALETTE: case FF_PIXEL_PALETTE:
img_copy_plane(dst->data[0], dst->linesize[0], ff_img_copy_plane(dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], src->data[0], src->linesize[0],
width, height); width, height);
/* copy the palette */ /* copy the palette */
img_copy_plane(dst->data[1], dst->linesize[1], ff_img_copy_plane(dst->data[1], dst->linesize[1],
src->data[1], src->linesize[1], src->data[1], src->linesize[1],
4, 256); 4, 256);
break; break;
...@@ -1210,7 +1210,7 @@ static void shrink12(uint8_t *dst, int dst_wrap, ...@@ -1210,7 +1210,7 @@ static void shrink12(uint8_t *dst, int dst_wrap,
} }
/* 2x2 -> 1x1 */ /* 2x2 -> 1x1 */
static void shrink22(uint8_t *dst, int dst_wrap, void ff_shrink22(uint8_t *dst, int dst_wrap,
const uint8_t *src, int src_wrap, const uint8_t *src, int src_wrap,
int width, int height) int width, int height)
{ {
...@@ -1243,7 +1243,7 @@ static void shrink22(uint8_t *dst, int dst_wrap, ...@@ -1243,7 +1243,7 @@ static void shrink22(uint8_t *dst, int dst_wrap,
} }
/* 4x4 -> 1x1 */ /* 4x4 -> 1x1 */
static void shrink44(uint8_t *dst, int dst_wrap, void ff_shrink44(uint8_t *dst, int dst_wrap,
const uint8_t *src, int src_wrap, const uint8_t *src, int src_wrap,
int width, int height) int width, int height)
{ {
...@@ -1273,6 +1273,28 @@ static void shrink44(uint8_t *dst, int dst_wrap, ...@@ -1273,6 +1273,28 @@ static void shrink44(uint8_t *dst, int dst_wrap,
} }
} }
/* 8x8 -> 1x1 */
void ff_shrink88(uint8_t *dst, int dst_wrap,
const uint8_t *src, int src_wrap,
int width, int height)
{
int w, i;
for(;height > 0; height--) {
for(w = width;w > 0; w--) {
int tmp=0;
for(i=0; i<8; i++){
tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
src += src_wrap;
}
*(dst++) = (tmp + 32)>>6;
src += 8 - 8*src_wrap;
}
src += 8*src_wrap - 8*width;
dst += dst_wrap - width;
}
}
static void grow21_line(uint8_t *dst, const uint8_t *src, static void grow21_line(uint8_t *dst, const uint8_t *src,
int width) int width)
{ {
...@@ -2023,7 +2045,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt, ...@@ -2023,7 +2045,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
uint8_t *d; uint8_t *d;
if (dst_pix->color_type == FF_COLOR_YUV_JPEG) { if (dst_pix->color_type == FF_COLOR_YUV_JPEG) {
img_copy_plane(dst->data[0], dst->linesize[0], ff_img_copy_plane(dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], src->data[0], src->linesize[0],
dst_width, dst_height); dst_width, dst_height);
} else { } else {
...@@ -2051,7 +2073,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt, ...@@ -2051,7 +2073,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
if (is_yuv_planar(src_pix) && if (is_yuv_planar(src_pix) &&
dst_pix_fmt == PIX_FMT_GRAY8) { dst_pix_fmt == PIX_FMT_GRAY8) {
if (src_pix->color_type == FF_COLOR_YUV_JPEG) { if (src_pix->color_type == FF_COLOR_YUV_JPEG) {
img_copy_plane(dst->data[0], dst->linesize[0], ff_img_copy_plane(dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], src->data[0], src->linesize[0],
dst_width, dst_height); dst_width, dst_height);
} else { } else {
...@@ -2089,7 +2111,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt, ...@@ -2089,7 +2111,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
YUV444 format */ YUV444 format */
switch(xy_shift) { switch(xy_shift) {
case 0x00: case 0x00:
resize_func = img_copy_plane; resize_func = ff_img_copy_plane;
break; break;
case 0x10: case 0x10:
resize_func = shrink21; resize_func = shrink21;
...@@ -2101,10 +2123,10 @@ int img_convert(AVPicture *dst, int dst_pix_fmt, ...@@ -2101,10 +2123,10 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
resize_func = shrink12; resize_func = shrink12;
break; break;
case 0x11: case 0x11:
resize_func = shrink22; resize_func = ff_shrink22;
break; break;
case 0x22: case 0x22:
resize_func = shrink44; resize_func = ff_shrink44;
break; break;
case 0xf0: case 0xf0:
resize_func = grow21; resize_func = grow21;
...@@ -2126,7 +2148,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt, ...@@ -2126,7 +2148,7 @@ int img_convert(AVPicture *dst, int dst_pix_fmt,
goto no_chroma_filter; goto no_chroma_filter;
} }
img_copy_plane(dst->data[0], dst->linesize[0], ff_img_copy_plane(dst->data[0], dst->linesize[0],
src->data[0], src->linesize[0], src->data[0], src->linesize[0],
dst_width, dst_height); dst_width, dst_height);
......
...@@ -2180,10 +2180,11 @@ static int estimate_best_b_count(MpegEncContext *s){ ...@@ -2180,10 +2180,11 @@ static int estimate_best_b_count(MpegEncContext *s){
int i, j, out_size, p_lambda, b_lambda, lambda2; int i, j, out_size, p_lambda, b_lambda, lambda2;
int outbuf_size= s->width * s->height; //FIXME int outbuf_size= s->width * s->height; //FIXME
uint8_t *outbuf= av_malloc(outbuf_size); uint8_t *outbuf= av_malloc(outbuf_size);
ImgReSampleContext *resample;
int64_t best_rd= INT64_MAX; int64_t best_rd= INT64_MAX;
int best_b_count= -1; int best_b_count= -1;
assert(scale>=0 && scale <=3);
// emms_c(); // emms_c();
p_lambda= s->last_lambda_for[P_TYPE]; //s->next_picture_ptr->quality; p_lambda= s->last_lambda_for[P_TYPE]; //s->next_picture_ptr->quality;
b_lambda= s->last_lambda_for[B_TYPE]; //p_lambda *ABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; b_lambda= s->last_lambda_for[B_TYPE]; //p_lambda *ABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
...@@ -2205,8 +2206,6 @@ static int estimate_best_b_count(MpegEncContext *s){ ...@@ -2205,8 +2206,6 @@ static int estimate_best_b_count(MpegEncContext *s){
if (avcodec_open(c, codec) < 0) if (avcodec_open(c, codec) < 0)
return -1; return -1;
resample= img_resample_init(c->width, c->height, s->width, s->height); //FIXME use sws
for(i=0; i<s->max_b_frames+2; i++){ for(i=0; i<s->max_b_frames+2; i++){
int ysize= c->width*c->height; int ysize= c->width*c->height;
int csize= (c->width/2)*(c->height/2); int csize= (c->width/2)*(c->height/2);
...@@ -2229,9 +2228,11 @@ static int estimate_best_b_count(MpegEncContext *s){ ...@@ -2229,9 +2228,11 @@ static int estimate_best_b_count(MpegEncContext *s){
input[i].linesize[1]= input[i].linesize[1]=
input[i].linesize[2]= c->width/2; input[i].linesize[2]= c->width/2;
if(!i || s->input_picture[i-1]) if(!i || s->input_picture[i-1]){
img_resample(resample, (AVPicture*)&input[i], s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height);
(AVPicture*)&pre_input); s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1);
s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1);
}
} }
for(j=0; j<s->max_b_frames+1; j++){ for(j=0; j<s->max_b_frames+1; j++){
...@@ -2273,7 +2274,6 @@ static int estimate_best_b_count(MpegEncContext *s){ ...@@ -2273,7 +2274,6 @@ static int estimate_best_b_count(MpegEncContext *s){
av_freep(&outbuf); av_freep(&outbuf);
avcodec_close(c); avcodec_close(c);
av_freep(&c); av_freep(&c);
img_resample_close(resample);
for(i=0; i<s->max_b_frames+2; i++){ for(i=0; i<s->max_b_frames+2; i++){
av_freep(&input[i].data[0]); av_freep(&input[i].data[0]);
......
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