annotate h263.c @ 11756:cec5a6f0beec libavcodec

VP8 decoding via libvpx. Patch by James Zern for Google, Inc., jzern google com
author cehoyos
date Tue, 25 May 2010 01:19:08 +0000
parents 7dd2a45249a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * H263/MPEG4 backend for ffmpeg encoder and decoder
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 8627
diff changeset
3 * Copyright (c) 2000,2001 Fabrice Bellard
78
92ed1c4f94fa Added support to Unrestricted Motion Vectors (UMV)
pulento
parents: 70
diff changeset
4 * H263+ support.
8629
04423b2f6e0b cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 8627
diff changeset
5 * Copyright (c) 2001 Juan J. Sierralta P
1739
07a484280a82 copyright year update of the files i touched and remembered, things look annoyingly unmaintained otherwise
michael
parents: 1708
diff changeset
6 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
8 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
9 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
10 * FFmpeg is free software; you can redistribute it and/or
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
11 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
12 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
13 * version 2.1 of the License, or (at your option) any later version.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
15 * FFmpeg is distributed in the hope that it will be useful,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
18 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 *
429
718a22dc121f license/copyright change
glantau
parents: 396
diff changeset
20 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3791
diff changeset
21 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 3024
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
23 */
1034
af7ba8d8b43a feeding doxygen
michaelni
parents: 1025
diff changeset
24
af7ba8d8b43a feeding doxygen
michaelni
parents: 1025
diff changeset
25 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 11531
diff changeset
26 * @file
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1092
diff changeset
27 * h263/mpeg4 codec.
1034
af7ba8d8b43a feeding doxygen
michaelni
parents: 1025
diff changeset
28 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
29
355
ac6fc4c7aecb - H263 PAR support by Alex Beregszaszi.
pulento
parents: 350
diff changeset
30 //#define DEBUG
1490
0355f2b3519a rate distortion optimal cbp support (h263/mpeg4 non intra only)
michaelni
parents: 1483
diff changeset
31 #include <limits.h>
0355f2b3519a rate distortion optimal cbp support (h263/mpeg4 non intra only)
michaelni
parents: 1483
diff changeset
32
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
33 #include "dsputil.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
34 #include "avcodec.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
35 #include "mpegvideo.h"
10803
4605bd2fdb7f Split the mpeg4 encoder and decoder off h263.c
michael
parents: 10799
diff changeset
36 #include "h263.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
37 #include "h263data.h"
8627
d6bab465b82c moves mid_pred() into mathops.h (with arch specific code split by directory)
aurel
parents: 8612
diff changeset
38 #include "mathops.h"
9103
b626fed816d7 Add PB-frame decoding support for H.263/i263 (and enable it for i263)
kostya
parents: 9093
diff changeset
39 #include "unary.h"
10787
3f8e40fe25c2 Split out flv encoding.
michael
parents: 10786
diff changeset
40 #include "flv.h"
10803
4605bd2fdb7f Split the mpeg4 encoder and decoder off h263.c
michael
parents: 10799
diff changeset
41 #include "mpeg4video.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
42
690
a1c69cb685b3 adaptive quantization (lumi/temporal & spatial complexity masking)
michaelni
parents: 676
diff changeset
43 //#undef NDEBUG
a1c69cb685b3 adaptive quantization (lumi/temporal & spatial complexity masking)
michaelni
parents: 676
diff changeset
44 //#include <assert.h>
a1c69cb685b3 adaptive quantization (lumi/temporal & spatial complexity masking)
michaelni
parents: 676
diff changeset
45
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents: 10824
diff changeset
46 uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
47
3247
ac7bfc9bf1a4 2x faster ff_mpeg4_set_direct_mv
lorenm
parents: 3205
diff changeset
48
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
49 void ff_h263_update_motion_val(MpegEncContext * s){
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
50 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
2646
c735e3e60ca7 Even More spelling errors. patch by (Kevin Baragona <kevinmb500 gawab com)
michael
parents: 2639
diff changeset
51 //FIXME a lot of that is only needed for !low_delay
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
52 const int wrap = s->b8_stride;
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
53 const int xy = s->block_index[0];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
54
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
55 s->current_picture.mbskip_table[mb_xy]= s->mb_skipped;
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
56
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
57 if(s->mv_type != MV_TYPE_8X8){
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
58 int motion_x, motion_y;
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
59 if (s->mb_intra) {
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
60 motion_x = 0;
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
61 motion_y = 0;
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
62 } else if (s->mv_type == MV_TYPE_16X16) {
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
63 motion_x = s->mv[0][0][0];
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
64 motion_y = s->mv[0][0][1];
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
65 } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
66 int i;
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
67 motion_x = s->mv[0][0][0] + s->mv[0][1][0];
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
68 motion_y = s->mv[0][0][1] + s->mv[0][1][1];
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
69 motion_x = (motion_x>>1) | (motion_x&1);
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
70 for(i=0; i<2; i++){
1708
dea5b2946999 interlaced motion estimation
michael
parents: 1701
diff changeset
71 s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
dea5b2946999 interlaced motion estimation
michael
parents: 1701
diff changeset
72 s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
73 }
11531
31033caa5344 Change ref_index structure so it matches how its organized in h264.
michael
parents: 10828
diff changeset
74 s->current_picture.ref_index[0][4*mb_xy ]=
31033caa5344 Change ref_index structure so it matches how its organized in h264.
michael
parents: 10828
diff changeset
75 s->current_picture.ref_index[0][4*mb_xy + 1]= s->field_select[0][0];
31033caa5344 Change ref_index structure so it matches how its organized in h264.
michael
parents: 10828
diff changeset
76 s->current_picture.ref_index[0][4*mb_xy + 2]=
31033caa5344 Change ref_index structure so it matches how its organized in h264.
michael
parents: 10828
diff changeset
77 s->current_picture.ref_index[0][4*mb_xy + 3]= s->field_select[0][1];
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
78 }
1948
d10578f7fd40 exporting field_select/ref_index values
michael
parents: 1944
diff changeset
79
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
80 /* no update if 8X8 because it has been done during parsing */
1668
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
81 s->current_picture.motion_val[0][xy][0] = motion_x;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
82 s->current_picture.motion_val[0][xy][1] = motion_y;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
83 s->current_picture.motion_val[0][xy + 1][0] = motion_x;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
84 s->current_picture.motion_val[0][xy + 1][1] = motion_y;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
85 s->current_picture.motion_val[0][xy + wrap][0] = motion_x;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
86 s->current_picture.motion_val[0][xy + wrap][1] = motion_y;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
87 s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_x;
30746f429df6 move motion_val & mb_type to AVFrame patch by (Wolfgang Hesseler <qv at multimediaware dot com>)
michael
parents: 1666
diff changeset
88 s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_y;
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
89 }
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
90
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
91 if(s->encoding){ //FIXME encoding MUST be cleaned up
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
92 if (s->mv_type == MV_TYPE_8X8)
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
93 s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_8x8;
1633
27806cccec2a h263 OBMC & 4MV support
michael
parents: 1598
diff changeset
94 else if(s->mb_intra)
27806cccec2a h263 OBMC & 4MV support
michael
parents: 1598
diff changeset
95 s->current_picture.mb_type[mb_xy]= MB_TYPE_INTRA;
1389
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
96 else
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
97 s->current_picture.mb_type[mb_xy]= MB_TYPE_L0 | MB_TYPE_16x16;
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
98 }
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
99 }
da0b3a50d209 rate distortion mb decision support
michaelni
parents: 1366
diff changeset
100
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents: 10824
diff changeset
101 int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
10752
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
102 {
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
103 int x, y, wrap, a, c, pred_dc;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
104 int16_t *dc_val;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
105
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
106 /* find prediction */
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
107 if (n < 4) {
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
108 x = 2 * s->mb_x + (n & 1);
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
109 y = 2 * s->mb_y + ((n & 2) >> 1);
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
110 wrap = s->b8_stride;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
111 dc_val = s->dc_val[0];
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
112 } else {
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
113 x = s->mb_x;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
114 y = s->mb_y;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
115 wrap = s->mb_stride;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
116 dc_val = s->dc_val[n - 4 + 1];
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
117 }
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
118 /* B C
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
119 * A X
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
120 */
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
121 a = dc_val[(x - 1) + (y) * wrap];
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
122 c = dc_val[(x) + (y - 1) * wrap];
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
123
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
124 /* No prediction outside GOB boundary */
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
125 if(s->first_slice_line && n!=3){
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
126 if(n!=2) c= 1024;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
127 if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
128 }
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
129 /* just DC prediction */
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
130 if (a != 1024 && c != 1024)
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
131 pred_dc = (a + c) >> 1;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
132 else if (a != 1024)
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
133 pred_dc = a;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
134 else
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
135 pred_dc = c;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
136
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
137 /* we assume pred is positive */
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
138 *dc_val_ptr = &dc_val[x + y * wrap];
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
139 return pred_dc;
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
140 }
56e57dc0fe19 cosmetics: Move H.263-related functions around to avoid forward declarations.
diego
parents: 10726
diff changeset
141
1656
34b0e799aeb6 cleanup
michael
parents: 1655
diff changeset
142 void ff_h263_loop_filter(MpegEncContext * s){
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
143 int qp_c;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
144 const int linesize = s->linesize;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
145 const int uvlinesize= s->uvlinesize;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
146 const int xy = s->mb_y * s->mb_stride + s->mb_x;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
147 uint8_t *dest_y = s->dest[0];
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
148 uint8_t *dest_cb= s->dest[1];
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
149 uint8_t *dest_cr= s->dest[2];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
150
6481
493dc59d469a add FF_ prefix to all (frame)_TYPE usage
aurel
parents: 6211
diff changeset
151 // if(s->pict_type==FF_B_TYPE && !s->readable) return;
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
152
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
153 /*
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
154 Diag Top
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
155 Left Center
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
156 */
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
157 if(!IS_SKIP(s->current_picture.mb_type[xy])){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
158 qp_c= s->qscale;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
159 s->dsp.h263_v_loop_filter(dest_y+8*linesize , linesize, qp_c);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
160 s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
161 }else
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
162 qp_c= 0;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
163
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
164 if(s->mb_y){
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
165 int qp_dt, qp_tt, qp_tc;
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
166
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
167 if(IS_SKIP(s->current_picture.mb_type[xy-s->mb_stride]))
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
168 qp_tt=0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
169 else
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
170 qp_tt= s->current_picture.qscale_table[xy-s->mb_stride];
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
171
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
172 if(qp_c)
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
173 qp_tc= qp_c;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
174 else
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
175 qp_tc= qp_tt;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
176
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
177 if(qp_tc){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
178 const int chroma_qp= s->chroma_qscale_table[qp_tc];
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
179 s->dsp.h263_v_loop_filter(dest_y , linesize, qp_tc);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
180 s->dsp.h263_v_loop_filter(dest_y+8, linesize, qp_tc);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
181
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
182 s->dsp.h263_v_loop_filter(dest_cb , uvlinesize, chroma_qp);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
183 s->dsp.h263_v_loop_filter(dest_cr , uvlinesize, chroma_qp);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
184 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
185
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
186 if(qp_tt)
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
187 s->dsp.h263_h_loop_filter(dest_y-8*linesize+8 , linesize, qp_tt);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
188
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
189 if(s->mb_x){
8297
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
190 if(qp_tt || IS_SKIP(s->current_picture.mb_type[xy-1-s->mb_stride]))
20e0f0809b27 s/qp_t/qp_tt/ to avoid bad examples that could lead to issues with reserved
michael
parents: 8288
diff changeset
191 qp_dt= qp_tt;
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
192 else
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
193 qp_dt= s->current_picture.qscale_table[xy-1-s->mb_stride];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
194
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
195 if(qp_dt){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
196 const int chroma_qp= s->chroma_qscale_table[qp_dt];
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
197 s->dsp.h263_h_loop_filter(dest_y -8*linesize , linesize, qp_dt);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
198 s->dsp.h263_h_loop_filter(dest_cb-8*uvlinesize, uvlinesize, chroma_qp);
2178
f140ada1f755 copy & paste bug
michael
parents: 2167
diff changeset
199 s->dsp.h263_h_loop_filter(dest_cr-8*uvlinesize, uvlinesize, chroma_qp);
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
200 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
201 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
202 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
203
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
204 if(qp_c){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
205 s->dsp.h263_h_loop_filter(dest_y +8, linesize, qp_c);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
206 if(s->mb_y + 1 == s->mb_height)
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
207 s->dsp.h263_h_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
208 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
209
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
210 if(s->mb_x){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
211 int qp_lc;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
212 if(qp_c || IS_SKIP(s->current_picture.mb_type[xy-1]))
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
213 qp_lc= qp_c;
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
214 else
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
215 qp_lc= s->current_picture.qscale_table[xy-1];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
216
1644
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
217 if(qp_lc){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
218 s->dsp.h263_h_loop_filter(dest_y, linesize, qp_lc);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
219 if(s->mb_y + 1 == s->mb_height){
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
220 const int chroma_qp= s->chroma_qscale_table[qp_lc];
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
221 s->dsp.h263_h_loop_filter(dest_y +8* linesize, linesize, qp_lc);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
222 s->dsp.h263_h_loop_filter(dest_cb , uvlinesize, chroma_qp);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
223 s->dsp.h263_h_loop_filter(dest_cr , uvlinesize, chroma_qp);
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
224 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
225 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
226 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
227 }
835cf346975e h263 loop filter
michael
parents: 1641
diff changeset
228
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents: 10824
diff changeset
229 void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
230 {
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
231 int x, y, wrap, a, c, pred_dc, scale, i;
3781
8e79b099d354 dc_val should be signed
mru
parents: 3777
diff changeset
232 int16_t *dc_val, *ac_val, *ac_val1;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
233
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
234 /* find prediction */
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
235 if (n < 4) {
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
236 x = 2 * s->mb_x + (n & 1);
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
237 y = 2 * s->mb_y + (n>> 1);
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
238 wrap = s->b8_stride;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
239 dc_val = s->dc_val[0];
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
240 ac_val = s->ac_val[0][0];
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
241 scale = s->y_dc_scale;
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
242 } else {
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
243 x = s->mb_x;
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
244 y = s->mb_y;
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
245 wrap = s->mb_stride;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
246 dc_val = s->dc_val[n - 4 + 1];
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
247 ac_val = s->ac_val[n - 4 + 1][0];
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
248 scale = s->c_dc_scale;
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
249 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
250
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
251 ac_val += ((y) * wrap + (x)) * 16;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
252 ac_val1 = ac_val;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
253
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
254 /* B C
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
255 * A X
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
256 */
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
257 a = dc_val[(x - 1) + (y) * wrap];
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
258 c = dc_val[(x) + (y - 1) * wrap];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
259
350
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 346
diff changeset
260 /* No prediction outside GOB boundary */
1639
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
261 if(s->first_slice_line && n!=3){
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
262 if(n!=2) c= 1024;
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
263 if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
264 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
265
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
266 if (s->ac_pred) {
1639
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
267 pred_dc = 1024;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
268 if (s->h263_aic_dir) {
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
269 /* left prediction */
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
270 if (a != 1024) {
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
271 ac_val -= 16;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
272 for(i=1;i<8;i++) {
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1090
diff changeset
273 block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
274 }
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
275 pred_dc = a;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
276 }
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
277 } else {
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
278 /* top prediction */
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
279 if (c != 1024) {
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
280 ac_val -= 16 * wrap;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
281 for(i=1;i<8;i++) {
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1090
diff changeset
282 block[s->dsp.idct_permutation[i ]] += ac_val[i + 8];
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
283 }
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
284 pred_dc = c;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
285 }
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
286 }
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
287 } else {
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
288 /* just DC prediction */
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
289 if (a != 1024 && c != 1024)
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
290 pred_dc = (a + c) >> 1;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
291 else if (a != 1024)
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
292 pred_dc = a;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
293 else
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
294 pred_dc = c;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
295 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
296
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
297 /* we assume pred is positive */
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
298 block[0]=block[0]*scale + pred_dc;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
299
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
300 if (block[0] < 0)
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
301 block[0] = 0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
302 else
1639
3e2b774edce4 rv20 decoder
michael
parents: 1637
diff changeset
303 block[0] |= 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
304
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
305 /* Update AC/DC tables */
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
306 dc_val[(x) + (y) * wrap] = block[0];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
307
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
308 /* left copy */
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
309 for(i=1;i<8;i++)
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1090
diff changeset
310 ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
311 /* top copy */
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
312 for(i=1;i<8;i++)
1092
f59c3f66363b MpegEncContext.(i)dct_* -> DspContext.(i)dct_*
michaelni
parents: 1090
diff changeset
313 ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
314 }
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 245
diff changeset
315
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
316 int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 int *px, int *py)
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 {
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
319 int wrap;
1655
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
320 int16_t *A, *B, *C, (*mot_val)[2];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
321 static const int off[4]= {2, 1, 1, -1};
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
322
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
323 wrap = s->b8_stride;
1938
e2501e6e7ff7 unify table indexing (motion_val,dc_val,ac_val,coded_block changed)
michael
parents: 1936
diff changeset
324 mot_val = s->current_picture.motion_val[dir] + s->block_index[block];
1655
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
325
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
326 A = mot_val[ - 1];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
327 /* special case for first (slice) line */
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
328 if (s->first_slice_line && block<3) {
2646
c735e3e60ca7 Even More spelling errors. patch by (Kevin Baragona <kevinmb500 gawab com)
michael
parents: 2639
diff changeset
329 // we can't just change some MVs to simulate that as we need them for the B frames (and ME)
1655
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
330 // and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
331 if(block==0){ //most common case
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
332 if(s->mb_x == s->resync_mb_x){ //rare
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
333 *px= *py = 0;
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
334 }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
335 C = mot_val[off[block] - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
336 if(s->mb_x==0){
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
337 *px = C[0];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
338 *py = C[1];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
339 }else{
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
340 *px = mid_pred(A[0], 0, C[0]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
341 *py = mid_pred(A[1], 0, C[1]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
342 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
343 }else{
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
344 *px = A[0];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
345 *py = A[1];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
346 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
347 }else if(block==1){
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
348 if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
349 C = mot_val[off[block] - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
350 *px = mid_pred(A[0], 0, C[0]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
351 *py = mid_pred(A[1], 0, C[1]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
352 }else{
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
353 *px = A[0];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
354 *py = A[1];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
355 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
356 }else{ /* block==2*/
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
357 B = mot_val[ - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
358 C = mot_val[off[block] - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
359 if(s->mb_x == s->resync_mb_x) //rare
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
360 A[0]=A[1]=0;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2966
diff changeset
361
1655
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
362 *px = mid_pred(A[0], B[0], C[0]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
363 *py = mid_pred(A[1], B[1], C[1]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
364 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
365 } else {
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
366 B = mot_val[ - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
367 C = mot_val[off[block] - wrap];
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
368 *px = mid_pred(A[0], B[0], C[0]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
369 *py = mid_pred(A[1], B[1], C[1]);
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
370 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
371 return *mot_val;
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
372 }
c92147a61d97 rv20 (h263) b frame decoding support
michael
parents: 1652
diff changeset
373
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
374
745
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
375 /**
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
376 * Get the GOB height based on picture height.
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
377 */
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
378 int ff_h263_get_gob_height(MpegEncContext *s){
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
379 if (s->height <= 400)
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
380 return 1;
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
381 else if (s->height <= 800)
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
382 return 2;
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
383 else
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
384 return 4;
25d7fb7c89be better/cleaner error resilience (done in a 2nd pass after decoding)
michaelni
parents: 718
diff changeset
385 }