1 /*
2 * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
29
32
35
36 #undef NDEBUG
37 #include <assert.h>
38
43 int x, y, mb_x;
45 int block_w = plane_index ? block_size>>s->
chroma_h_shift : block_size;
46 int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
48 int obmc_stride= plane_index ? (2*block_size)>>s->
chroma_h_shift : 2*block_size;
53
55 if(mb_y==mb_h)
56 return;
57
58 if(add){
59 for(y=block_h*mb_y; y<
FFMIN(h,block_h*(mb_y+1)); y++){
60 // DWTELEM * line = slice_buffer_get_line(sb, y);
62 for(x=0; x<w; x++){
63 // int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
66 if(v&(~255)) v= ~(v>>31);
67 dst8[x + y*ref_stride]= v;
68 }
69 }
70 }else{
71 for(y=block_h*mb_y; y<
FFMIN(h,block_h*(mb_y+1)); y++){
72 // DWTELEM * line = slice_buffer_get_line(sb, y);
74 for(x=0; x<w; x++){
76 // buf[x + y*w]-= 128<<FRAC_BITS;
77 }
78 }
79 }
80
81 return;
82 }
83
84 for(mb_x=0; mb_x<=mb_w; mb_x++){
86 block_w*mb_x - block_w/2,
87 block_h*mb_y - block_h/2,
88 block_w, block_h,
89 w, h,
90 w, ref_stride, obmc_stride,
91 mb_x - 1, mb_y - 1,
92 add, 0, plane_index);
93 }
94 }
95
97 const int w= b->
width;
98 int y;
102 int new_index = 0;
103
105 qadd= 0;
107 }
108
109 /* If we are on the second or later slice, restore our index. */
110 if (start_y != 0)
111 new_index = save_state[0];
112
113
114 for(y=start_y; y<h; y++){
115 int x = 0;
116 int v;
121 while(x < w){
122 register int t= ( (v>>1)*qmul + qadd)>>
QEXPSHIFT;
123 register int u= -(v&1);
124 line[x] = (t^u) - u;
125
128 }
129 }
130
131 /* Save our variables for the next slice. */
132 save_state[0] = new_index;
133
134 return;
135 }
136
140 const int index= (x + y*w) << rem_depth;
141 int trx= (x+1)<<rem_depth;
145 const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->
block[index-w+(1<<rem_depth)] : tl;
//FIXME use lt
147 int res;
148
150 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);
151 return 0;
152 }
153
155 int type, mx, my;
156 int l = left->
color[0];
159 int ref = 0;
163
165
166 if(type){
167 pred_mv(s, &mx, &my, 0, left, top, tr);
171 }else{
177 }
178 pred_mv(s, &mx, &my, ref, left, top, tr);
181 }
182 set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);
183 }else{
188 return res;
189 }
190 return 0;
191 }
192
194 const int w= b->
width;
198 int x,y;
199
201
202 for(y=start_y; y<end_y; y++){
203 // DWTELEM * line = slice_buffer_get_line_from_address(sb, src + (y * stride));
205 for(x=0; x<w; x++){
206 int i= line[x];
207 if(i<0){
208 line[x]= -((-i*qmul + qadd)>>(
QEXPSHIFT));
//FIXME try different bias
209 }else if(i>0){
210 line[x]= (( i*qmul + qadd)>>(
QEXPSHIFT));
211 }
212 }
213 }
214 }
215
217 const int w= b->
width;
218 int x,y;
219
220 IDWTELEM *
line=0;
// silence silly "could be used without having been initialized" warning
222
223 if (start_y != 0)
225
226 for(y=start_y; y<end_y; y++){
227 prev = line;
228 // line = slice_buffer_get_line_from_address(sb, src + (y * stride));
230 for(x=0; x<w; x++){
231 if(x){
232 if(use_median){
233 if(y && x+1<w) line[x] +=
mid_pred(line[x - 1], prev[x], prev[x + 1]);
234 else line[x] += line[x - 1];
235 }else{
236 if(y) line[x] +=
mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
237 else line[x] += line[x - 1];
238 }
239 }else{
240 if(y) line[x] += prev[x];
241 }
242 }
243 }
244 }
245
247 int plane_index,
level, orientation;
248
249 for(plane_index=0; plane_index<3; plane_index++){
251 for(orientation=level ? 1:0; orientation<4; orientation++){
252 int q;
257 }
258 }
259 }
260 }
261
262 #define GET_S(dst, check) \
263 tmp= get_symbol(&s->c, s->header_state, 0);\
264 if(!(check)){\
265 av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
266 return -1;\
267 }\
268 dst= tmp;
269
271 int plane_index, tmp;
273
274 memset(kstate,
MID_STATE,
sizeof(kstate));
275
284 }
294
301 } else {
306 }
307
309 // s->rate_scalability= get_rac(&s->c, s->header_state);
312
314 }
315
318 for(plane_index=0; plane_index<2; plane_index++){
319 int htaps, i, sum=0;
323 if((
unsigned)htaps >
HTAPS_MAX || htaps==0)
324 return -1;
326 for(i= htaps/2; i; i--){
329 }
331 }
335 }
339 }
340 }
341
345 return -1;
346 }
350 return -1;
351 }
352
353
361 return -1;
362 }
363
364 return 0;
365 }
366
368 {
369 int ret;
370
373 return ret;
374 }
375
376 return 0;
377 }
378
380 int x, y;
383 int res;
384
385 for(y=0; y<h; y++){
386 for(x=0; x<w; x++){
388 return res;
389 }
390 }
391 return 0;
392 }
393
396 {
398 int buf_size = avpkt->
size;
401 int bytes_read;
403 int level, orientation, plane_index;
404 int res;
405
408
411 return -1;
413 return res;
414
415 // realloc slice buffer for the case that spatial_decomposition_count changed
422 return res;
423
424 for(plane_index=0; plane_index<3; plane_index++){
429 }
430
432
434 return -1;
435 //keyframe flag duplication mess FIXME
438
440 return res;
441
442 for(plane_index=0; plane_index<3; plane_index++){
446 int x, y;
447 int decode_state[
MAX_DECOMPOSITIONS][4][1];
/* Stored state info for unpack_coeffs. 1 variable per instance. */
448
452
453 for(y=0; y<h; y++){
454 for(x=0; x<w; x++){
457 }
458 }
459 }
460
461 {
463 for(orientation=level ? 1 : 0; orientation<4; orientation++){
466 }
467 }
468 }
469
470 {
473 const int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
474 int mb_y;
476 int yd=0, yq=0;
477 int y;
478 int end_y;
479
481 for(mb_y=0; mb_y<=mb_h; mb_y++){
482
483 int slice_starty = block_h*mb_y;
484 int slice_h = block_h*(mb_y+1);
485
487 slice_starty =
FFMAX(0, slice_starty - (block_h >> 1));
488 slice_h -= (block_h >> 1);
489 }
490
492 for(orientation=level ? 1 : 0; orientation<4; orientation++){
494 int start_y;
495 int end_y;
496 int our_mb_start = mb_y;
497 int our_mb_end = (mb_y + 1);
498 const int extra= 3;
504 }
507
508 if (start_y != end_y){
509 if (orientation == 0){
512 int correlate_start_y =
FFMIN(b->
height, (start_y ? start_y + 1 : 0));
516 }
517 else
519 }
520 }
521 }
522
523 for(; yd<slice_h; yd+=4){
525 }
526
528 for(; yq<slice_h && yq<h; yq++){
530 for(x=0; x<w; x++){
532 }
533 }
534 }
535
537
540 while(y < end_y)
542 }
543
545 }
546
547 }
548
550
552
555 else
557
558 *got_frame = 1;
559
562
563 return bytes_read;
564 }
565
567 {
569
571
573
574 return 0;
575 }
576
585 .capabilities =
CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
587 };