Commit d9669eab authored by Ronald S. Bultje's avatar Ronald S. Bultje Committed by Mans Rullgard

dwt: remove variable-length arrays

Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
parent 8e50c57d
This diff is collapsed.
...@@ -50,7 +50,7 @@ typedef struct DWTContext { ...@@ -50,7 +50,7 @@ typedef struct DWTContext {
void (*vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, void (*vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5,
int width); int width);
void (*horizontal_compose97i)(IDWTELEM *b, int width); void (*horizontal_compose97i)(IDWTELEM *b, IDWTELEM *temp, int width);
void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride, void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride,
uint8_t **block, int b_w, int b_h, int src_x, uint8_t **block, int b_w, int b_h, int src_x,
int src_y, int src_stride, slice_buffer *sb, int src_y, int src_stride, slice_buffer *sb,
...@@ -148,7 +148,7 @@ IDWTELEM *ff_slice_buffer_load_line(slice_buffer *buf, int line); ...@@ -148,7 +148,7 @@ IDWTELEM *ff_slice_buffer_load_line(slice_buffer *buf, int line);
void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2,
IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5,
int width); int width);
void ff_snow_horizontal_compose97i(IDWTELEM *b, int width); void ff_snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width);
void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride,
uint8_t **block, int b_w, int b_h, int src_x, uint8_t **block, int b_w, int b_h, int src_x,
int src_y, int src_stride, slice_buffer *sb, int src_y, int src_stride, slice_buffer *sb,
...@@ -157,18 +157,18 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, ...@@ -157,18 +157,18 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride,
int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, void ff_spatial_dwt(int *buffer, int *temp, int width, int height, int stride,
int decomposition_count); int type, int decomposition_count);
void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width, void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width,
int height, int stride_line, int type, int height, int stride_line, int type,
int decomposition_count); int decomposition_count);
void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs, void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs,
slice_buffer *slice_buf, int width, slice_buffer *slice_buf, IDWTELEM *temp,
int height, int stride_line, int type, int width, int height, int stride_line,
int decomposition_count, int y); int type, int decomposition_count, int y);
void ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride, void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height,
int type, int decomposition_count); int stride, int type, int decomposition_count);
void ff_dwt_init(DWTContext *c); void ff_dwt_init(DWTContext *c);
void ff_dwt_init_x86(DWTContext *c); void ff_dwt_init_x86(DWTContext *c);
......
...@@ -440,6 +440,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){ ...@@ -440,6 +440,8 @@ av_cold int ff_snow_common_init(AVCodecContext *avctx){
s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM)); s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM));
s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this does not belong here
s->temp_dwt_buffer = av_mallocz(width * sizeof(DWTELEM));
s->temp_idwt_buffer = av_mallocz(width * sizeof(IDWTELEM));
for(i=0; i<MAX_REF_FRAMES; i++) for(i=0; i<MAX_REF_FRAMES; i++)
for(j=0; j<MAX_REF_FRAMES; j++) for(j=0; j<MAX_REF_FRAMES; j++)
...@@ -618,7 +620,9 @@ av_cold void ff_snow_common_end(SnowContext *s) ...@@ -618,7 +620,9 @@ av_cold void ff_snow_common_end(SnowContext *s)
int plane_index, level, orientation, i; int plane_index, level, orientation, i;
av_freep(&s->spatial_dwt_buffer); av_freep(&s->spatial_dwt_buffer);
av_freep(&s->temp_dwt_buffer);
av_freep(&s->spatial_idwt_buffer); av_freep(&s->spatial_idwt_buffer);
av_freep(&s->temp_idwt_buffer);
s->m.me.temp= NULL; s->m.me.temp= NULL;
av_freep(&s->m.me.scratchpad); av_freep(&s->m.me.scratchpad);
......
...@@ -132,7 +132,9 @@ typedef struct SnowContext{ ...@@ -132,7 +132,9 @@ typedef struct SnowContext{
int16_t (*ref_mvs[MAX_REF_FRAMES])[2]; int16_t (*ref_mvs[MAX_REF_FRAMES])[2];
uint32_t *ref_scores[MAX_REF_FRAMES]; uint32_t *ref_scores[MAX_REF_FRAMES];
DWTELEM *spatial_dwt_buffer; DWTELEM *spatial_dwt_buffer;
DWTELEM *temp_dwt_buffer;
IDWTELEM *spatial_idwt_buffer; IDWTELEM *spatial_idwt_buffer;
IDWTELEM *temp_idwt_buffer;
int colorspace_type; int colorspace_type;
int chroma_h_shift; int chroma_h_shift;
int chroma_v_shift; int chroma_v_shift;
......
...@@ -502,7 +502,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac ...@@ -502,7 +502,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
} }
for(; yd<slice_h; yd+=4){ for(; yd<slice_h; yd+=4){
ff_spatial_idwt_buffered_slice(&s->dwt, cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count, yd); ff_spatial_idwt_buffered_slice(&s->dwt, cs, &s->sb, s->temp_idwt_buffer, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count, yd);
} }
if(s->qlog == LOSSLESS_QLOG){ if(s->qlog == LOSSLESS_QLOG){
......
...@@ -93,7 +93,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i ...@@ -93,7 +93,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
//FIXME pass the copy cleanly ? //FIXME pass the copy cleanly ?
// memcpy(dwt_buffer, buffer, height * stride * sizeof(DWTELEM)); // memcpy(dwt_buffer, buffer, height * stride * sizeof(DWTELEM));
ff_spatial_dwt(buffer, width, height, stride, type, s->spatial_decomposition_count); ff_spatial_dwt(buffer, s->temp_dwt_buffer, width, height, stride, type, s->spatial_decomposition_count);
for(level=0; level<s->spatial_decomposition_count; level++){ for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){ for(orientation=level ? 1 : 0; orientation<4; orientation++){
...@@ -118,7 +118,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i ...@@ -118,7 +118,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
for(xs= 0; xs<Q2_STEP; xs++){ for(xs= 0; xs<Q2_STEP; xs++){
memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM));
dequantize_all(s, p, idwt2_buffer, width, height); dequantize_all(s, p, idwt2_buffer, width, height);
ff_spatial_idwt(idwt2_buffer, width, height, stride, type, s->spatial_decomposition_count); ff_spatial_idwt(idwt2_buffer, s->temp_idwt_buffer, width, height, stride, type, s->spatial_decomposition_count);
find_sse(s, p, best_score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation); find_sse(s, p, best_score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation);
memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); memcpy(idwt2_buffer, best_dequant, height * stride * sizeof(IDWTELEM));
for(y=ys; y<b->height; y+= Q2_STEP){ for(y=ys; y<b->height; y+= Q2_STEP){
...@@ -129,7 +129,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i ...@@ -129,7 +129,7 @@ static void dwt_quantize(SnowContext *s, Plane *p, DWTELEM *buffer, int width, i
} }
} }
dequantize_all(s, p, idwt2_buffer, width, height); dequantize_all(s, p, idwt2_buffer, width, height);
ff_spatial_idwt(idwt2_buffer, width, height, stride, type, s->spatial_decomposition_count); ff_spatial_idwt(idwt2_buffer, s->temp_idwt_buffer, width, height, stride, type, s->spatial_decomposition_count);
find_sse(s, p, score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation); find_sse(s, p, score, score_stride, idwt2_buffer, s->spatial_idwt_buffer, level, orientation);
for(y=ys; y<b->height; y+= Q2_STEP){ for(y=ys; y<b->height; y+= Q2_STEP){
for(x=xs; x<b->width; x+= Q2_STEP){ for(x=xs; x<b->width; x+= Q2_STEP){
...@@ -1586,7 +1586,7 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){ ...@@ -1586,7 +1586,7 @@ static void calculate_visual_weight(SnowContext *s, Plane *p){
memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height); memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
ibuf[b->width/2 + b->height/2*b->stride]= 256*16; ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
ff_spatial_idwt(s->spatial_idwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count); ff_spatial_idwt(s->spatial_idwt_buffer, s->temp_idwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
for(y=0; y<height; y++){ for(y=0; y<height; y++){
for(x=0; x<width; x++){ for(x=0; x<width; x++){
int64_t d= s->spatial_idwt_buffer[x + y*width]*16; int64_t d= s->spatial_idwt_buffer[x + y*width]*16;
...@@ -1775,7 +1775,7 @@ redo_frame: ...@@ -1775,7 +1775,7 @@ redo_frame:
/* if(QUANTIZE2) /* if(QUANTIZE2)
dwt_quantize(s, p, s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type); dwt_quantize(s, p, s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type);
else*/ else*/
ff_spatial_dwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); ff_spatial_dwt(s->spatial_dwt_buffer, s->temp_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
if(s->pass1_rc && plane_index==0){ if(s->pass1_rc && plane_index==0){
int delta_qlog = ratecontrol_1pass(s, pic); int delta_qlog = ratecontrol_1pass(s, pic);
...@@ -1814,7 +1814,7 @@ redo_frame: ...@@ -1814,7 +1814,7 @@ redo_frame:
} }
} }
ff_spatial_idwt(s->spatial_idwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count); ff_spatial_idwt(s->spatial_idwt_buffer, s->temp_idwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
if(s->qlog == LOSSLESS_QLOG){ if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){ for(y=0; y<h; y++){
for(x=0; x<w; x++){ for(x=0; x<w; x++){
......
...@@ -26,9 +26,8 @@ ...@@ -26,9 +26,8 @@
#include "libavcodec/dwt.h" #include "libavcodec/dwt.h"
#include "dsputil_mmx.h" #include "dsputil_mmx.h"
static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, int width){ static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, IDWTELEM *temp, int width){
const int w2= (width+1)>>1; const int w2= (width+1)>>1;
DECLARE_ALIGNED(16, IDWTELEM, temp)[width>>1];
const int w_l= (width>>1); const int w_l= (width>>1);
const int w_r= w2 - 1; const int w_r= w2 - 1;
int i; int i;
...@@ -215,9 +214,8 @@ static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, int width){ ...@@ -215,9 +214,8 @@ static void ff_snow_horizontal_compose97i_sse2(IDWTELEM *b, int width){
} }
} }
static void ff_snow_horizontal_compose97i_mmx(IDWTELEM *b, int width){ static void ff_snow_horizontal_compose97i_mmx(IDWTELEM *b, IDWTELEM *temp, int width){
const int w2= (width+1)>>1; const int w2= (width+1)>>1;
IDWTELEM temp[width >> 1];
const int w_l= (width>>1); const int w_l= (width>>1);
const int w_r= w2 - 1; const int w_r= w2 - 1;
int i; int i;
......
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