---
libavcodec/snow.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/snow.h | 2 +-
libavcodec/snowdec.c | 55 +-------------------------------------------------
libavcodec/snowenc.c | 55 +-------------------------------------------------
4 files changed, 58 insertions(+), 109 deletions(-)
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 65adf88..c4d8717 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -450,3 +450,58 @@ av_cold int snow_common_init(AVCodecContext *avctx){
return 0;
}
+
+int snow_common_init_after_header(AVCodecContext *avctx) {
+ SnowContext *s = avctx->priv_data;
+ int plane_index, level, orientation;
+
+ for(plane_index=0; plane_index<3; plane_index++){
+ int w= s->avctx->width;
+ int h= s->avctx->height;
+
+ if(plane_index){
+ w>>= s->chroma_h_shift;
+ h>>= s->chroma_v_shift;
+ }
+ s->plane[plane_index].width = w;
+ s->plane[plane_index].height= h;
+
+ for(level=s->spatial_decomposition_count-1; level>=0; level--){
+ for(orientation=level ? 1 : 0; orientation<4; orientation++){
+ SubBand *b= &s->plane[plane_index].band[level][orientation];
+
+ b->buf= s->spatial_dwt_buffer;
+ b->level= level;
+ b->stride= s->plane[plane_index].width <<
(s->spatial_decomposition_count - level);
+ b->width = (w + !(orientation&1))>>1;
+ b->height= (h + !(orientation>1))>>1;
+
+ b->stride_line = 1 << (s->spatial_decomposition_count - level);
+ b->buf_x_offset = 0;
+ b->buf_y_offset = 0;
+
+ if(orientation&1){
+ b->buf += (w+1)>>1;
+ b->buf_x_offset = (w+1)>>1;
+ }
+ if(orientation>1){
+ b->buf += b->stride>>1;
+ b->buf_y_offset = b->stride_line >> 1;
+ }
+ b->ibuf= s->spatial_idwt_buffer + (b->buf -
s->spatial_dwt_buffer);
+
+ if(level)
+ b->parent=
&s->plane[plane_index].band[level-1][orientation];
+ //FIXME avoid this realloc
+ av_freep(&b->x_coeff);
+ b->x_coeff=av_mallocz(((b->width+1) *
b->height+1)*sizeof(x_and_coeff));
+ }
+ w= (w+1)>>1;
+ h= (h+1)>>1;
+ }
+ }
+
+ return 0;
+}
+
+
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index 34d6688..0fa5a37 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -219,7 +219,7 @@ int snow_common_init(AVCodecContext *avctx);
void snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, int stride,
int sx, int sy, int b_w, int b_h, BlockNode *block,
int plane_index, int w, int h);
-
+int snow_common_init_after_header(AVCodecContext *avctx);
/* common inline functions */
//XXX doublecheck all of them should stay inlined
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index 7423990..b456a50 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -588,59 +588,6 @@ static int decode_header(SnowContext *s){
return 0;
}
-static int common_init_after_header(AVCodecContext *avctx){
- SnowContext *s = avctx->priv_data;
- int plane_index, level, orientation;
-
- for(plane_index=0; plane_index<3; plane_index++){
- int w= s->avctx->width;
- int h= s->avctx->height;
-
- if(plane_index){
- w>>= s->chroma_h_shift;
- h>>= s->chroma_v_shift;
- }
- s->plane[plane_index].width = w;
- s->plane[plane_index].height= h;
-
- for(level=s->spatial_decomposition_count-1; level>=0; level--){
- for(orientation=level ? 1 : 0; orientation<4; orientation++){
- SubBand *b= &s->plane[plane_index].band[level][orientation];
-
- b->buf= s->spatial_dwt_buffer;
- b->level= level;
- b->stride= s->plane[plane_index].width <<
(s->spatial_decomposition_count - level);
- b->width = (w + !(orientation&1))>>1;
- b->height= (h + !(orientation>1))>>1;
-
- b->stride_line = 1 << (s->spatial_decomposition_count - level);
- b->buf_x_offset = 0;
- b->buf_y_offset = 0;
-
- if(orientation&1){
- b->buf += (w+1)>>1;
- b->buf_x_offset = (w+1)>>1;
- }
- if(orientation>1){
- b->buf += b->stride>>1;
- b->buf_y_offset = b->stride_line >> 1;
- }
- b->ibuf= s->spatial_idwt_buffer + (b->buf -
s->spatial_dwt_buffer);
-
- if(level)
- b->parent=
&s->plane[plane_index].band[level-1][orientation];
- //FIXME avoid this realloc
- av_freep(&b->x_coeff);
- b->x_coeff=av_mallocz(((b->width+1) *
b->height+1)*sizeof(x_and_coeff));
- }
- w= (w+1)>>1;
- h= (h+1)>>1;
- }
- }
-
- return 0;
-}
-
#define QUANTIZE2 0
#if QUANTIZE2==1
@@ -870,7 +817,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
int *data_size, AVPac
s->current_picture.pict_type= AV_PICTURE_TYPE_I; //FIXME I vs. P
if(decode_header(s)<0)
return -1;
- common_init_after_header(avctx);
+ snow_common_init_after_header(avctx);
// realloc slice buffer for the case that spatial_decomposition_count
changed
ff_slice_buffer_destroy(&s->sb);
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 2e7feee..3ccdaf9 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -283,59 +283,6 @@ static inline void init_ref(MotionEstContext *c, uint8_t
*src[3], uint8_t *ref[3
assert(!ref_index);
}
-static int common_init_after_header(AVCodecContext *avctx){
- SnowContext *s = avctx->priv_data;
- int plane_index, level, orientation;
-
- for(plane_index=0; plane_index<3; plane_index++){
- int w= s->avctx->width;
- int h= s->avctx->height;
-
- if(plane_index){
- w>>= s->chroma_h_shift;
- h>>= s->chroma_v_shift;
- }
- s->plane[plane_index].width = w;
- s->plane[plane_index].height= h;
-
- for(level=s->spatial_decomposition_count-1; level>=0; level--){
- for(orientation=level ? 1 : 0; orientation<4; orientation++){
- SubBand *b= &s->plane[plane_index].band[level][orientation];
-
- b->buf= s->spatial_dwt_buffer;
- b->level= level;
- b->stride= s->plane[plane_index].width <<
(s->spatial_decomposition_count - level);
- b->width = (w + !(orientation&1))>>1;
- b->height= (h + !(orientation>1))>>1;
-
- b->stride_line = 1 << (s->spatial_decomposition_count - level);
- b->buf_x_offset = 0;
- b->buf_y_offset = 0;
-
- if(orientation&1){
- b->buf += (w+1)>>1;
- b->buf_x_offset = (w+1)>>1;
- }
- if(orientation>1){
- b->buf += b->stride>>1;
- b->buf_y_offset = b->stride_line >> 1;
- }
- b->ibuf= s->spatial_idwt_buffer + (b->buf -
s->spatial_dwt_buffer);
-
- if(level)
- b->parent=
&s->plane[plane_index].band[level-1][orientation];
- //FIXME avoid this realloc
- av_freep(&b->x_coeff);
- b->x_coeff=av_mallocz(((b->width+1) *
b->height+1)*sizeof(x_and_coeff));
- }
- w= (w+1)>>1;
- h= (h+1)>>1;
- }
- }
-
- return 0;
-}
-
#define QUANTIZE2 0
#if QUANTIZE2==1
@@ -2155,7 +2102,7 @@ redo_frame:
s->m.pict_type = pict->pict_type;
s->qbias= pict->pict_type == AV_PICTURE_TYPE_P ? 2 : 0;
- common_init_after_header(avctx);
+ snow_common_init_after_header(avctx);
if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){
for(plane_index=0; plane_index<3; plane_index++){
--
1.7.7
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel