Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/snow.h')
-rw-r--r--libavcodec/snow.h50
1 files changed, 28 insertions, 22 deletions
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index abf330962c..6d6b086907 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -2,20 +2,20 @@
* Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at>
* Copyright (C) 2006 Robert Edele <yartrebo@earthlink.net>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -161,6 +161,7 @@ typedef struct SnowContext{
unsigned me_cache_generation;
slice_buffer sb;
int memc_only;
+ int no_bitstream;
MpegEncContext m; // needed for motion estimation, should not be used for anything else, the idea is to eventually make the motion estimation independent of MpegEncContext, so this will be removed then (FIXME/XXX)
@@ -326,7 +327,7 @@ static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer
if(b_w<=0 || b_h<=0) return;
- assert(src_stride > 2*MB_SIZE + 5);
+ av_assert2(src_stride > 2*MB_SIZE + 5);
if(!sliced && offset_dst)
dst += src_x + src_y*dst_stride;
@@ -404,20 +405,21 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl
const int mb_h= s->b_height << s->block_max_depth;
int x, y, mb_x;
int block_size = MB_SIZE >> s->block_max_depth;
- int block_w = plane_index ? block_size/2 : block_size;
- const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+1] : ff_obmc_tab[s->block_max_depth];
- const int obmc_stride= plane_index ? block_size : 2*block_size;
+ int block_w = plane_index ? block_size>>s->chroma_h_shift : block_size;
+ int block_h = plane_index ? block_size>>s->chroma_v_shift : block_size;
+ const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth];
+ const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *dst8= s->current_picture.data[plane_index];
int w= p->width;
int h= p->height;
-
+ av_assert2(s->chroma_h_shift == s->chroma_v_shift); // obmc params assume squares
if(s->keyframe || (s->avctx->debug&512)){
if(mb_y==mb_h)
return;
if(add){
- for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
+ for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
for(x=0; x<w; x++){
int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
v >>= FRAC_BITS;
@@ -426,7 +428,7 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl
}
}
}else{
- for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++){
+ for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
for(x=0; x<w; x++){
buf[x + y*w]-= 128<<FRAC_BITS;
}
@@ -439,8 +441,8 @@ static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int pl
for(mb_x=0; mb_x<=mb_w; mb_x++){
add_yblock(s, 0, NULL, buf, dst8, obmc,
block_w*mb_x - block_w/2,
- block_w*mb_y - block_w/2,
- block_w, block_w,
+ block_h*mb_y - block_h/2,
+ block_w, block_h,
w, h,
w, ref_stride, obmc_stride,
mb_x - 1, mb_y - 1,
@@ -460,6 +462,7 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
const int block_w= 1<<rem_depth;
+ const int block_h= 1<<rem_depth; //FIXME "w!=h"
BlockNode block;
int i,j;
@@ -472,7 +475,7 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in
block.type= type;
block.level= level;
- for(j=0; j<block_w; j++){
+ for(j=0; j<block_h; j++){
for(i=0; i<block_w; i++){
s->block[index + i + j*w]= block;
}
@@ -480,17 +483,18 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in
}
static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
+ SnowContext *s = c->avctx->priv_data;
const int offset[3]= {
y*c-> stride + x,
- ((y*c->uvstride + x)>>1),
- ((y*c->uvstride + x)>>1),
+ ((y*c->uvstride + x)>>s->chroma_h_shift),
+ ((y*c->uvstride + x)>>s->chroma_h_shift),
};
int i;
for(i=0; i<3; i++){
c->src[0][i]= src [i];
c->ref[0][i]= ref [i] + offset[i];
}
- assert(!ref_index);
+ av_assert2(!ref_index);
}
@@ -555,8 +559,8 @@ static inline void put_symbol2(RangeCoder *c, uint8_t *state, int v, int log2){
int i;
int r= log2>=0 ? 1<<log2 : 1;
- assert(v>=0);
- assert(log2>=-4);
+ av_assert2(v>=0);
+ av_assert2(log2>=-4);
while(v >= r){
put_rac(c, state+4+log2, 1);
@@ -576,9 +580,9 @@ static inline int get_symbol2(RangeCoder *c, uint8_t *state, int log2){
int r= log2>=0 ? 1<<log2 : 1;
int v=0;
- assert(log2>=-4);
+ av_assert2(log2>=-4);
- while(get_rac(c, state+4+log2)){
+ while(log2<28 && get_rac(c, state+4+log2)){
v+= r;
log2++;
if(log2>0) r+=r;
@@ -660,11 +664,13 @@ static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, i
int max_run;
run--;
v=0;
-
+ av_assert2(run >= 0);
if(y) max_run= FFMIN(run, prev_xc->x - x - 2);
else max_run= FFMIN(run, w-x-1);
if(parent_xc)
max_run= FFMIN(max_run, 2*parent_xc->x - x - 1);
+ av_assert2(max_run >= 0 && max_run <= run);
+
x+= max_run;
run-= max_run;
}