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
28
31
34
41 int block_w = plane_index ? block_size>>s->
chroma_h_shift : block_size;
42 int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
44 int obmc_stride= plane_index ? (2*block_size)>>s->
chroma_h_shift : 2*block_size;
49
51 if(mb_y==mb_h)
52 return;
53
54 if(add){
55 for(y=block_h*mb_y; y<
FFMIN(h,block_h*(mb_y+1)); y++){
56 // DWTELEM * line = slice_buffer_get_line(sb, y);
58 for(x=0; x<w; x++){
59 // int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
62 if(v&(~255)) v= ~(v>>31);
63 dst8[x + y*ref_stride]=
v;
64 }
65 }
66 }else{
67 for(y=block_h*mb_y; y<
FFMIN(h,block_h*(mb_y+1)); y++){
68 // DWTELEM * line = slice_buffer_get_line(sb, y);
70 for(x=0; x<w; x++){
72 // buf[x + y*w]-= 128<<FRAC_BITS;
73 }
74 }
75 }
76
77 return;
78 }
79
80 for(mb_x=0; mb_x<=mb_w; mb_x++){
82 block_w*mb_x - block_w/2,
83 block_h*mb_y - block_h/2,
84 block_w, block_h,
85 w, h,
86 w, ref_stride, obmc_stride,
87 mb_x - 1, mb_y - 1,
88 add, 0, plane_index);
89 }
90
91 if(s->
avmv && mb_y < mb_h && plane_index == 0)
92 for(mb_x=0; mb_x<mb_w; mb_x++){
95 const int b_stride= b_width;
97
99 continue;
100
102
105 avmv->
dst_x = block_w*mb_x - block_w/2;
106 avmv->
dst_y = block_h*mb_y - block_h/2;
111 }
112 }
113
115 const int w= b->
width;
120 int new_index = 0;
121
123 qadd= 0;
125 }
126
127 /* If we are on the second or later slice, restore our index. */
128 if (start_y != 0)
129 new_index = save_state[0];
130
131
132 for(y=start_y; y<h; y++){
133 int x = 0;
139 while(x < w){
140 register int t= ( (v>>1)*qmul + qadd)>>
QEXPSHIFT;
141 register int u= -(v&1);
143
146 }
147 }
148
149 /* Save our variables for the next slice. */
150 save_state[0] = new_index;
151
152 return;
153 }
154
158 const int index= (x + y*w) << rem_depth;
159 int trx= (x+1)<<rem_depth;
163 const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->
block[index-w+(1<<rem_depth)] : tl;
//FIXME use lt
165 int res;
166
168 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);
169 return 0;
170 }
171
174 int l = left->
color[0];
177 unsigned ref = 0;
181
183
184 if(type){
185 pred_mv(s, &mx, &my, 0, left, top, tr);
190 }
191 }else{
197 }
198 pred_mv(s, &mx, &my, ref, left, top, tr);
201 }
202 set_blocks(s, level, x, y, l, cb, cr, mx, my, ref, type);
203 }else{
208 return res;
209 }
210 return 0;
211 }
212
214 const int w= b->
width;
219
221
222 for(y=start_y; y<end_y; y++){
223 // DWTELEM * line = slice_buffer_get_line_from_address(sb, src + (y * stride));
225 for(x=0; x<w; x++){
226 int i= line[x];
227 if(i<0){
228 line[x]= -((-i*qmul + qadd)>>(
QEXPSHIFT));
//FIXME try different bias
229 }else if(i>0){
230 line[x]= (( i*qmul + qadd)>>(
QEXPSHIFT));
231 }
232 }
233 }
234 }
235
237 const int w= b->
width;
239
240 IDWTELEM *
line=0;
// silence silly "could be used without having been initialized" warning
242
243 if (start_y != 0)
245
246 for(y=start_y; y<end_y; y++){
247 prev = line;
248 // line = slice_buffer_get_line_from_address(sb, src + (y * stride));
250 for(x=0; x<w; x++){
251 if(x){
252 if(use_median){
253 if(y && x+1<w) line[x] +=
mid_pred(line[x - 1], prev[x], prev[x + 1]);
254 else line[x] += line[x - 1];
255 }else{
256 if(y) line[x] +=
mid_pred(line[x - 1], prev[x], line[x - 1] + prev[x] - prev[x - 1]);
257 else line[x] += line[x - 1];
258 }
259 }else{
260 if(y) line[x] += prev[x];
261 }
262 }
263 }
264 }
265
267 int plane_index,
level, orientation;
268
269 for(plane_index=0; plane_index < s->
nb_planes; plane_index++){
271 for(orientation=level ? 1:0; orientation<4; orientation++){
272 int q;
277 }
278 }
279 }
280 }
281
282 #define GET_S(dst, check) \
283 tmp= get_symbol(&s->c, s->header_state, 0);\
284 if(!(check)){\
285 av_log(s->avctx, AV_LOG_ERROR, "Error " #dst " is %d\n", tmp);\
286 return AVERROR_INVALIDDATA;\
287 }\
288 dst= tmp;
289
291 int plane_index, tmp;
293
294 memset(kstate,
MID_STATE,
sizeof(kstate));
295
304 }
318
325 } else {
330 }
332 } else {
337 }
338
339
341 // s->rate_scalability= get_rac(&s->c, s->header_state);
344
346 }
347
350 for(plane_index=0; plane_index<
FFMIN(s->
nb_planes, 2); plane_index++){
355 if((
unsigned)htaps >
HTAPS_MAX || htaps==0)
358 for(i= htaps/2; i; i--){
361 }
363 }
367 }
371 }
372 }
373
378 }
383 }
384
385
394 }
395
396 return 0;
397 }
398
400 {
402
406 }
407
408 return 0;
409 }
410
415 int res;
416
417 for(y=0; y<h; y++){
418 for(x=0; x<w; x++){
420 return res;
421 }
422 }
423 return 0;
424 }
425
428 {
430 int buf_size = avpkt->
size;
433 int bytes_read;
435 int level, orientation, plane_index;
436 int res;
437
440
443 return res;
445 return res;
446
447 // realloc slice buffer for the case that spatial_decomposition_count changed
454 return res;
455
456 for(plane_index=0; plane_index < s->
nb_planes; plane_index++){
461 }
462
464
466 return res;
467
469
470 //keyframe flag duplication mess FIXME
473 "keyframe:%d qlog:%d qbias: %d mvscale: %d "
474 "decomposition_type:%d decomposition_count:%d\n",
478 );
479
483 }
485
487 return res;
488
489 for(plane_index=0; plane_index < s->
nb_planes; plane_index++){
494 int decode_state[
MAX_DECOMPOSITIONS][4][1];
/* Stored state info for unpack_coeffs. 1 variable per instance. */
495
499
500 for(y=0; y<h; y++){
501 for(x=0; x<w; x++){
504 }
505 }
506 }
507
508 {
510 for(orientation=level ? 1 : 0; orientation<4; orientation++){
513 }
514 }
515 }
516
517 {
520 const int block_h = plane_index ? block_size>>s->
chroma_v_shift : block_size;
521 int mb_y;
523 int yd=0, yq=0;
525 int end_y;
526
528 for(mb_y=0; mb_y<=mb_h; mb_y++){
529
530 int slice_starty = block_h*mb_y;
531 int slice_h = block_h*(mb_y+1);
532
534 slice_starty =
FFMAX(0, slice_starty - (block_h >> 1));
535 slice_h -= (block_h >> 1);
536 }
537
539 for(orientation=level ? 1 : 0; orientation<4; orientation++){
541 int start_y;
542 int end_y;
543 int our_mb_start = mb_y;
544 int our_mb_end = (mb_y + 1);
545 const int extra= 3;
551 }
554
555 if (start_y != end_y){
556 if (orientation == 0){
559 int correlate_start_y =
FFMIN(b->
height, (start_y ? start_y + 1 : 0));
563 }
564 else
566 }
567 }
568 }
569
570 for(; yd<slice_h; yd+=4){
572 }
573
575 for(; yq<slice_h && yq<h; yq++){
577 for(x=0; x<w; x++){
579 }
580 }
581 }
582
584
587 while(y < end_y)
589 }
590
592 }
593
594 }
595
596 emms_c();
597
599
602 else
606
608 if (!sd)
611 }
612
614
615 if (res < 0)
616 return res;
617
618 *got_frame = 1;
619
622
623 return bytes_read;
624 }
625
627 {
629
631
633
634 return 0;
635 }
636
646 .capabilities =
CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
647 };