00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libavutil/intmath.h"
00022 #include "libavutil/log.h"
00023 #include "libavutil/opt.h"
00024 #include "avcodec.h"
00025 #include "dsputil.h"
00026 #include "dwt.h"
00027 #include "snow.h"
00028
00029 #include "rangecoder.h"
00030 #include "mathops.h"
00031
00032 #include "mpegvideo.h"
00033 #include "h263.h"
00034
00035 #undef NDEBUG
00036 #include <assert.h>
00037
00038 static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){
00039 Plane *p= &s->plane[plane_index];
00040 const int mb_w= s->b_width << s->block_max_depth;
00041 const int mb_h= s->b_height << s->block_max_depth;
00042 int x, y, mb_x;
00043 int block_size = MB_SIZE >> s->block_max_depth;
00044 int block_w = plane_index ? block_size>>s->chroma_h_shift : block_size;
00045 int block_h = plane_index ? block_size>>s->chroma_v_shift : block_size;
00046 const uint8_t *obmc = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth];
00047 int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
00048 int ref_stride= s->current_picture.linesize[plane_index];
00049 uint8_t *dst8= s->current_picture.data[plane_index];
00050 int w= p->width;
00051 int h= p->height;
00052
00053 if(s->keyframe || (s->avctx->debug&512)){
00054 if(mb_y==mb_h)
00055 return;
00056
00057 if(add){
00058 for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
00059
00060 IDWTELEM * line = sb->line[y];
00061 for(x=0; x<w; x++){
00062
00063 int v= line[x] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
00064 v >>= FRAC_BITS;
00065 if(v&(~255)) v= ~(v>>31);
00066 dst8[x + y*ref_stride]= v;
00067 }
00068 }
00069 }else{
00070 for(y=block_h*mb_y; y<FFMIN(h,block_h*(mb_y+1)); y++){
00071
00072 IDWTELEM * line = sb->line[y];
00073 for(x=0; x<w; x++){
00074 line[x] -= 128 << FRAC_BITS;
00075
00076 }
00077 }
00078 }
00079
00080 return;
00081 }
00082
00083 for(mb_x=0; mb_x<=mb_w; mb_x++){
00084 add_yblock(s, 1, sb, old_buffer, dst8, obmc,
00085 block_w*mb_x - block_w/2,
00086 block_h*mb_y - block_h/2,
00087 block_w, block_h,
00088 w, h,
00089 w, ref_stride, obmc_stride,
00090 mb_x - 1, mb_y - 1,
00091 add, 0, plane_index);
00092 }
00093 }
00094
00095 static inline void decode_subband_slice_buffered(SnowContext *s, SubBand *b, slice_buffer * sb, int start_y, int h, int save_state[1]){
00096 const int w= b->width;
00097 int y;
00098 const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
00099 int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
00100 int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
00101 int new_index = 0;
00102
00103 if(b->ibuf == s->spatial_idwt_buffer || s->qlog == LOSSLESS_QLOG){
00104 qadd= 0;
00105 qmul= 1<<QEXPSHIFT;
00106 }
00107
00108
00109 if (start_y != 0)
00110 new_index = save_state[0];
00111
00112
00113 for(y=start_y; y<h; y++){
00114 int x = 0;
00115 int v;
00116 IDWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset;
00117 memset(line, 0, b->width*sizeof(IDWTELEM));
00118 v = b->x_coeff[new_index].coeff;
00119 x = b->x_coeff[new_index++].x;
00120 while(x < w){
00121 register int t= ( (v>>1)*qmul + qadd)>>QEXPSHIFT;
00122 register int u= -(v&1);
00123 line[x] = (t^u) - u;
00124
00125 v = b->x_coeff[new_index].coeff;
00126 x = b->x_coeff[new_index++].x;
00127 }
00128 }
00129
00130
00131 save_state[0] = new_index;
00132
00133 return;
00134 }
00135
00136 static int decode_q_branch(SnowContext *s, int level, int x, int y){
00137 const int w= s->b_width << s->block_max_depth;
00138 const int rem_depth= s->block_max_depth - level;
00139 const int index= (x + y*w) << rem_depth;
00140 int trx= (x+1)<<rem_depth;
00141 const BlockNode *left = x ? &s->block[index-1] : &null_block;
00142 const BlockNode *top = y ? &s->block[index-w] : &null_block;
00143 const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
00144 const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl;
00145 int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
00146 int res;
00147
00148 if(s->keyframe){
00149 set_blocks(s, level, x, y, null_block.color[0], null_block.color[1], null_block.color[2], null_block.mx, null_block.my, null_block.ref, BLOCK_INTRA);
00150 return 0;
00151 }
00152
00153 if(level==s->block_max_depth || get_rac(&s->c, &s->block_state[4 + s_context])){
00154 int type, mx, my;
00155 int l = left->color[0];
00156 int cb= left->color[1];
00157 int cr= left->color[2];
00158 int ref = 0;
00159 int ref_context= av_log2(2*left->ref) + av_log2(2*top->ref);
00160 int mx_context= av_log2(2*FFABS(left->mx - top->mx)) + 0*av_log2(2*FFABS(tr->mx - top->mx));
00161 int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my));
00162
00163 type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0;
00164
00165 if(type){
00166 pred_mv(s, &mx, &my, 0, left, top, tr);
00167 l += get_symbol(&s->c, &s->block_state[32], 1);
00168 cb+= get_symbol(&s->c, &s->block_state[64], 1);
00169 cr+= get_symbol(&s->c, &s->block_state[96], 1);
00170 }else{
00171 if(s->ref_frames > 1)
00172 ref= get_symbol(&s->c, &s->block_state[128 + 1024 + 32*ref_context], 0);
00173 if (ref >= s->ref_frames) {
00174 av_log(s->avctx, AV_LOG_ERROR, "Invalid ref\n");
00175 return AVERROR_INVALIDDATA;
00176 }
00177 pred_mv(s, &mx, &my, ref, left, top, tr);
00178 mx+= get_symbol(&s->c, &s->block_state[128 + 32*(mx_context + 16*!!ref)], 1);
00179 my+= get_symbol(&s->c, &s->block_state[128 + 32*(my_context + 16*!!ref)], 1);
00180 }
00181 set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);
00182 }else{
00183 if ((res = decode_q_branch(s, level+1, 2*x+0, 2*y+0)) < 0 ||
00184 (res = decode_q_branch(s, level+1, 2*x+1, 2*y+0)) < 0 ||
00185 (res = decode_q_branch(s, level+1, 2*x+0, 2*y+1)) < 0 ||
00186 (res = decode_q_branch(s, level+1, 2*x+1, 2*y+1)) < 0)
00187 return res;
00188 }
00189 return 0;
00190 }
00191
00192 static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){
00193 const int w= b->width;
00194 const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
00195 const int qmul= ff_qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
00196 const int qadd= (s->qbias*qmul)>>QBIAS_SHIFT;
00197 int x,y;
00198
00199 if(s->qlog == LOSSLESS_QLOG) return;
00200
00201 for(y=start_y; y<end_y; y++){
00202
00203 IDWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
00204 for(x=0; x<w; x++){
00205 int i= line[x];
00206 if(i<0){
00207 line[x]= -((-i*qmul + qadd)>>(QEXPSHIFT));
00208 }else if(i>0){
00209 line[x]= (( i*qmul + qadd)>>(QEXPSHIFT));
00210 }
00211 }
00212 }
00213 }
00214
00215 static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
00216 const int w= b->width;
00217 int x,y;
00218
00219 IDWTELEM * line=0;
00220 IDWTELEM * prev;
00221
00222 if (start_y != 0)
00223 line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
00224
00225 for(y=start_y; y<end_y; y++){
00226 prev = line;
00227
00228 line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
00229 for(x=0; x<w; x++){
00230 if(x){
00231 if(use_median){
00232 if(y && x+1<w) line[x] += mid_pred(line[x - 1], prev[x], prev[x + 1]);
00233 else line[x] += line[x - 1];
00234 }else{
00235 if(y) line[x] += mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
00236 else line[x] += line[x - 1];
00237 }
00238 }else{
00239 if(y) line[x] += prev[x];
00240 }
00241 }
00242 }
00243 }
00244
00245 static void decode_qlogs(SnowContext *s){
00246 int plane_index, level, orientation;
00247
00248 for(plane_index=0; plane_index<3; plane_index++){
00249 for(level=0; level<s->spatial_decomposition_count; level++){
00250 for(orientation=level ? 1:0; orientation<4; orientation++){
00251 int q;
00252 if (plane_index==2) q= s->plane[1].band[level][orientation].qlog;
00253 else if(orientation==2) q= s->plane[plane_index].band[level][1].qlog;
00254 else q= get_symbol(&s->c, s->header_state, 1);
00255 s->plane[plane_index].band[level][orientation].qlog= q;
00256 }
00257 }
00258 }
00259 }
00260
00261 #define GET_S(dst, check) \
00262 tmp= get_symbol(&s->c, s->header_state, 0);\
00263 if(!(check)){\
00264 av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
00265 return -1;\
00266 }\
00267 dst= tmp;
00268
00269 static int decode_header(SnowContext *s){
00270 int plane_index, tmp;
00271 uint8_t kstate[32];
00272
00273 memset(kstate, MID_STATE, sizeof(kstate));
00274
00275 s->keyframe= get_rac(&s->c, kstate);
00276 if(s->keyframe || s->always_reset){
00277 ff_snow_reset_contexts(s);
00278 s->spatial_decomposition_type=
00279 s->qlog=
00280 s->qbias=
00281 s->mv_scale=
00282 s->block_max_depth= 0;
00283 }
00284 if(s->keyframe){
00285 GET_S(s->version, tmp <= 0U)
00286 s->always_reset= get_rac(&s->c, s->header_state);
00287 s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0);
00288 s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0);
00289 GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS)
00290 s->colorspace_type= get_symbol(&s->c, s->header_state, 0);
00291 s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0);
00292 s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0);
00293
00294 if(s->chroma_h_shift == 1 && s->chroma_v_shift==1){
00295 s->avctx->pix_fmt= PIX_FMT_YUV420P;
00296 }else if(s->chroma_h_shift == 0 && s->chroma_v_shift==0){
00297 s->avctx->pix_fmt= PIX_FMT_YUV444P;
00298 }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){
00299 s->avctx->pix_fmt= PIX_FMT_YUV410P;
00300 } else {
00301 av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift);
00302 s->chroma_h_shift = s->chroma_v_shift = 1;
00303 s->avctx->pix_fmt= PIX_FMT_YUV420P;
00304 return AVERROR_INVALIDDATA;
00305 }
00306
00307 s->spatial_scalability= get_rac(&s->c, s->header_state);
00308
00309 GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES)
00310 s->max_ref_frames++;
00311
00312 decode_qlogs(s);
00313 }
00314
00315 if(!s->keyframe){
00316 if(get_rac(&s->c, s->header_state)){
00317 for(plane_index=0; plane_index<2; plane_index++){
00318 int htaps, i, sum=0;
00319 Plane *p= &s->plane[plane_index];
00320 p->diag_mc= get_rac(&s->c, s->header_state);
00321 htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2;
00322 if((unsigned)htaps > HTAPS_MAX || htaps==0)
00323 return -1;
00324 p->htaps= htaps;
00325 for(i= htaps/2; i; i--){
00326 p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));
00327 sum += p->hcoeff[i];
00328 }
00329 p->hcoeff[0]= 32-sum;
00330 }
00331 s->plane[2].diag_mc= s->plane[1].diag_mc;
00332 s->plane[2].htaps = s->plane[1].htaps;
00333 memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff));
00334 }
00335 if(get_rac(&s->c, s->header_state)){
00336 GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS)
00337 decode_qlogs(s);
00338 }
00339 }
00340
00341 s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
00342 if(s->spatial_decomposition_type > 1U){
00343 av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported\n", s->spatial_decomposition_type);
00344 return -1;
00345 }
00346 if(FFMIN(s->avctx-> width>>s->chroma_h_shift,
00347 s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 0){
00348 av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size\n", s->spatial_decomposition_count);
00349 return -1;
00350 }
00351
00352
00353 s->qlog += get_symbol(&s->c, s->header_state, 1);
00354 s->mv_scale += get_symbol(&s->c, s->header_state, 1);
00355 s->qbias += get_symbol(&s->c, s->header_state, 1);
00356 s->block_max_depth+= get_symbol(&s->c, s->header_state, 1);
00357 if(s->block_max_depth > 1 || s->block_max_depth < 0){
00358 av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large\n", s->block_max_depth);
00359 s->block_max_depth= 0;
00360 return -1;
00361 }
00362
00363 return 0;
00364 }
00365
00366 static av_cold int decode_init(AVCodecContext *avctx)
00367 {
00368 int ret;
00369
00370 if ((ret = ff_snow_common_init(avctx)) < 0) {
00371 ff_snow_common_end(avctx->priv_data);
00372 return ret;
00373 }
00374
00375 return 0;
00376 }
00377
00378 static int decode_blocks(SnowContext *s){
00379 int x, y;
00380 int w= s->b_width;
00381 int h= s->b_height;
00382 int res;
00383
00384 for(y=0; y<h; y++){
00385 for(x=0; x<w; x++){
00386 if ((res = decode_q_branch(s, 0, x, y)) < 0)
00387 return res;
00388 }
00389 }
00390 return 0;
00391 }
00392
00393 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt){
00394 const uint8_t *buf = avpkt->data;
00395 int buf_size = avpkt->size;
00396 SnowContext *s = avctx->priv_data;
00397 RangeCoder * const c= &s->c;
00398 int bytes_read;
00399 AVFrame *picture = data;
00400 int level, orientation, plane_index;
00401 int res;
00402
00403 ff_init_range_decoder(c, buf, buf_size);
00404 ff_build_rac_states(c, 0.05*(1LL<<32), 256-8);
00405
00406 s->current_picture.pict_type= AV_PICTURE_TYPE_I;
00407 if(decode_header(s)<0)
00408 return -1;
00409 if ((res=ff_snow_common_init_after_header(avctx)) < 0)
00410 return res;
00411
00412
00413 ff_slice_buffer_destroy(&s->sb);
00414 if ((res = ff_slice_buffer_init(&s->sb, s->plane[0].height,
00415 (MB_SIZE >> s->block_max_depth) +
00416 s->spatial_decomposition_count * 11 + 1,
00417 s->plane[0].width,
00418 s->spatial_idwt_buffer)) < 0)
00419 return res;
00420
00421 for(plane_index=0; plane_index<3; plane_index++){
00422 Plane *p= &s->plane[plane_index];
00423 p->fast_mc= p->diag_mc && p->htaps==6 && p->hcoeff[0]==40
00424 && p->hcoeff[1]==-10
00425 && p->hcoeff[2]==2;
00426 }
00427
00428 ff_snow_alloc_blocks(s);
00429
00430 if(ff_snow_frame_start(s) < 0)
00431 return -1;
00432
00433 if(avctx->debug&FF_DEBUG_PICT_INFO)
00434 av_log(avctx, AV_LOG_ERROR, "keyframe:%d qlog:%d\n", s->keyframe, s->qlog);
00435
00436 if ((res = decode_blocks(s)) < 0)
00437 return res;
00438
00439 for(plane_index=0; plane_index<3; plane_index++){
00440 Plane *p= &s->plane[plane_index];
00441 int w= p->width;
00442 int h= p->height;
00443 int x, y;
00444 int decode_state[MAX_DECOMPOSITIONS][4][1];
00445
00446 if(s->avctx->debug&2048){
00447 memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h);
00448 predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
00449
00450 for(y=0; y<h; y++){
00451 for(x=0; x<w; x++){
00452 int v= s->current_picture.data[plane_index][y*s->current_picture.linesize[plane_index] + x];
00453 s->mconly_picture.data[plane_index][y*s->mconly_picture.linesize[plane_index] + x]= v;
00454 }
00455 }
00456 }
00457
00458 {
00459 for(level=0; level<s->spatial_decomposition_count; level++){
00460 for(orientation=level ? 1 : 0; orientation<4; orientation++){
00461 SubBand *b= &p->band[level][orientation];
00462 unpack_coeffs(s, b, b->parent, orientation);
00463 }
00464 }
00465 }
00466
00467 {
00468 const int mb_h= s->b_height << s->block_max_depth;
00469 const int block_size = MB_SIZE >> s->block_max_depth;
00470 const int block_h = plane_index ? block_size>>s->chroma_v_shift : block_size;
00471 int mb_y;
00472 DWTCompose cs[MAX_DECOMPOSITIONS];
00473 int yd=0, yq=0;
00474 int y;
00475 int end_y;
00476
00477 ff_spatial_idwt_buffered_init(cs, &s->sb, w, h, 1, s->spatial_decomposition_type, s->spatial_decomposition_count);
00478 for(mb_y=0; mb_y<=mb_h; mb_y++){
00479
00480 int slice_starty = block_h*mb_y;
00481 int slice_h = block_h*(mb_y+1);
00482
00483 if (!(s->keyframe || s->avctx->debug&512)){
00484 slice_starty = FFMAX(0, slice_starty - (block_h >> 1));
00485 slice_h -= (block_h >> 1);
00486 }
00487
00488 for(level=0; level<s->spatial_decomposition_count; level++){
00489 for(orientation=level ? 1 : 0; orientation<4; orientation++){
00490 SubBand *b= &p->band[level][orientation];
00491 int start_y;
00492 int end_y;
00493 int our_mb_start = mb_y;
00494 int our_mb_end = (mb_y + 1);
00495 const int extra= 3;
00496 start_y = (mb_y ? ((block_h * our_mb_start) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra: 0);
00497 end_y = (((block_h * our_mb_end) >> (s->spatial_decomposition_count - level)) + s->spatial_decomposition_count - level + extra);
00498 if (!(s->keyframe || s->avctx->debug&512)){
00499 start_y = FFMAX(0, start_y - (block_h >> (1+s->spatial_decomposition_count - level)));
00500 end_y = FFMAX(0, end_y - (block_h >> (1+s->spatial_decomposition_count - level)));
00501 }
00502 start_y = FFMIN(b->height, start_y);
00503 end_y = FFMIN(b->height, end_y);
00504
00505 if (start_y != end_y){
00506 if (orientation == 0){
00507 SubBand * correlate_band = &p->band[0][0];
00508 int correlate_end_y = FFMIN(b->height, end_y + 1);
00509 int correlate_start_y = FFMIN(b->height, (start_y ? start_y + 1 : 0));
00510 decode_subband_slice_buffered(s, correlate_band, &s->sb, correlate_start_y, correlate_end_y, decode_state[0][0]);
00511 correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y);
00512 dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, start_y, end_y);
00513 }
00514 else
00515 decode_subband_slice_buffered(s, b, &s->sb, start_y, end_y, decode_state[level][orientation]);
00516 }
00517 }
00518 }
00519
00520 for(; yd<slice_h; yd+=4){
00521 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);
00522 }
00523
00524 if(s->qlog == LOSSLESS_QLOG){
00525 for(; yq<slice_h && yq<h; yq++){
00526 IDWTELEM * line = slice_buffer_get_line(&s->sb, yq);
00527 for(x=0; x<w; x++){
00528 line[x] <<= FRAC_BITS;
00529 }
00530 }
00531 }
00532
00533 predict_slice_buffered(s, &s->sb, s->spatial_idwt_buffer, plane_index, 1, mb_y);
00534
00535 y = FFMIN(p->height, slice_starty);
00536 end_y = FFMIN(p->height, slice_h);
00537 while(y < end_y)
00538 ff_slice_buffer_release(&s->sb, y++);
00539 }
00540
00541 ff_slice_buffer_flush(&s->sb);
00542 }
00543
00544 }
00545
00546 emms_c();
00547
00548 ff_snow_release_buffer(avctx);
00549
00550 if(!(s->avctx->debug&2048))
00551 *picture= s->current_picture;
00552 else
00553 *picture= s->mconly_picture;
00554
00555 *data_size = sizeof(AVFrame);
00556
00557 bytes_read= c->bytestream - c->bytestream_start;
00558 if(bytes_read ==0) av_log(s->avctx, AV_LOG_ERROR, "error at end of frame\n");
00559
00560 return bytes_read;
00561 }
00562
00563 static av_cold int decode_end(AVCodecContext *avctx)
00564 {
00565 SnowContext *s = avctx->priv_data;
00566
00567 ff_slice_buffer_destroy(&s->sb);
00568
00569 ff_snow_common_end(s);
00570
00571 return 0;
00572 }
00573
00574 AVCodec ff_snow_decoder = {
00575 .name = "snow",
00576 .type = AVMEDIA_TYPE_VIDEO,
00577 .id = AV_CODEC_ID_SNOW,
00578 .priv_data_size = sizeof(SnowContext),
00579 .init = decode_init,
00580 .close = decode_end,
00581 .decode = decode_frame,
00582 .capabilities = CODEC_CAP_DR1 ,
00583 .long_name = NULL_IF_CONFIG_SMALL("Snow"),
00584 };