annotate ituh263dec.c @ 10989:79f2e73f3714 libavcodec

Remove is_complex from loop_filter() its useless there in its current form.
author michael
date Sun, 24 Jan 2010 17:02:44 +0000
parents 34a65026fa06
children d464f498e19f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1 /*
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
2 * ITU H263 bitstream decoder
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
3 * Copyright (c) 2000,2001 Fabrice Bellard
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
4 * H263+ support.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
5 * Copyright (c) 2001 Juan J. Sierralta P
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
6 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
7 *
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
8 * This file is part of FFmpeg.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
9 *
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
10 * FFmpeg is free software; you can redistribute it and/or
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
11 * modify it under the terms of the GNU Lesser General Public
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
12 * License as published by the Free Software Foundation; either
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
13 * version 2.1 of the License, or (at your option) any later version.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
14 *
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
15 * FFmpeg is distributed in the hope that it will be useful,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
18 * Lesser General Public License for more details.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
19 *
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
20 * You should have received a copy of the GNU Lesser General Public
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
21 * License along with FFmpeg; if not, write to the Free Software
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
23 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
24
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
25 /**
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
26 * @file libavcodec/ituh263dec.c
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
27 * h263 decoder.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
28 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
29
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
30 //#define DEBUG
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
31 #include <limits.h>
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
32
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
33 #include "dsputil.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
34 #include "avcodec.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
35 #include "mpegvideo.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
36 #include "h263.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
37 #include "mathops.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
38 #include "unary.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
39 #include "flv.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
40 #include "mpeg4video.h"
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
41
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
42 //#undef NDEBUG
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
43 //#include <assert.h>
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
44
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
45 // The defines below define the number of bits that are read at once for
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
46 // reading vlc values. Changing these may improve speed and data cache needs
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
47 // be aware though that decreasing them may need the number of stages that is
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
48 // passed to get_vlc* to be increased.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
49 #define MV_VLC_BITS 9
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
50 #define H263_MBTYPE_B_VLC_BITS 6
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
51 #define CBPC_B_VLC_BITS 3
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
52
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
53 static const int h263_mb_type_b_map[15]= {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
54 MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
55 MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
56 MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
57 MB_TYPE_L0 | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
58 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
59 MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
60 MB_TYPE_L1 | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
61 MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
62 MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
63 MB_TYPE_L0L1 | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
64 MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
65 MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
66 0, //stuffing
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
67 MB_TYPE_INTRA4x4 | MB_TYPE_CBP,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
68 MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
69 };
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
70
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
71 void ff_h263_show_pict_info(MpegEncContext *s){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
72 if(s->avctx->debug&FF_DEBUG_PICT_INFO){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
73 av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
74 s->qscale, av_get_pict_type_char(s->pict_type),
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
75 s->gb.size_in_bits, 1-s->no_rounding,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
76 s->obmc ? " AP" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
77 s->umvplus ? " UMV" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
78 s->h263_long_vectors ? " LONG" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
79 s->h263_plus ? " +" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
80 s->h263_aic ? " AIC" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
81 s->alt_inter_vlc ? " AIV" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
82 s->modified_quant ? " MQ" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
83 s->loop_filter ? " LOOP" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
84 s->h263_slice_structured ? " SS" : "",
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
85 s->avctx->time_base.den, s->avctx->time_base.num
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
86 );
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
87 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
88 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
89
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
90 /***********************************************/
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
91 /* decoding */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
92
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
93 VLC ff_h263_intra_MCBPC_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
94 VLC ff_h263_inter_MCBPC_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
95 VLC ff_h263_cbpy_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
96 static VLC mv_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
97 static VLC h263_mbtype_b_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
98 static VLC cbpc_b_vlc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
99
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
100 /* init vlcs */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
101
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
102 /* XXX: find a better solution to handle static init */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
103 void h263_decode_init_vlc(MpegEncContext *s)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
104 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
105 static int done = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
106
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
107 if (!done) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
108 done = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
109
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
110 INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
111 ff_h263_intra_MCBPC_bits, 1, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
112 ff_h263_intra_MCBPC_code, 1, 1, 72);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
113 INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
114 ff_h263_inter_MCBPC_bits, 1, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
115 ff_h263_inter_MCBPC_code, 1, 1, 198);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
116 INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
117 &ff_h263_cbpy_tab[0][1], 2, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
118 &ff_h263_cbpy_tab[0][0], 2, 1, 64);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
119 INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 33,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
120 &mvtab[0][1], 2, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
121 &mvtab[0][0], 2, 1, 538);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
122 init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
123 init_rl(&rl_intra_aic, ff_h263_static_rl_table_store[1]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
124 INIT_VLC_RL(ff_h263_rl_inter, 554);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
125 INIT_VLC_RL(rl_intra_aic, 554);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
126 INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
127 &h263_mbtype_b_tab[0][1], 2, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
128 &h263_mbtype_b_tab[0][0], 2, 1, 80);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
129 INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
130 &cbpc_b_tab[0][1], 2, 1,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
131 &cbpc_b_tab[0][0], 2, 1, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
132 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
133 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
134
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
135 int ff_h263_decode_mba(MpegEncContext *s)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
136 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
137 int i, mb_pos;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
138
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
139 for(i=0; i<6; i++){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
140 if(s->mb_num-1 <= ff_mba_max[i]) break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
141 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
142 mb_pos= get_bits(&s->gb, ff_mba_length[i]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
143 s->mb_x= mb_pos % s->mb_width;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
144 s->mb_y= mb_pos / s->mb_width;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
145
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
146 return mb_pos;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
147 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
148
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
149 /**
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
150 * decodes the group of blocks header or slice header.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
151 * @return <0 if an error occurred
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
152 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
153 static int h263_decode_gob_header(MpegEncContext *s)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
154 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
155 unsigned int val, gfid, gob_number;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
156 int left;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
157
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
158 /* Check for GOB Start Code */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
159 val = show_bits(&s->gb, 16);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
160 if(val)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
161 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
162
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
163 /* We have a GBSC probably with GSTUFF */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
164 skip_bits(&s->gb, 16); /* Drop the zeros */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
165 left= get_bits_left(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
166 //MN: we must check the bits left or we might end in a infinite loop (or segfault)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
167 for(;left>13; left--){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
168 if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
169 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
170 if(left<=13)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
171 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
172
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
173 if(s->h263_slice_structured){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
174 if(get_bits1(&s->gb)==0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
175 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
176
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
177 ff_h263_decode_mba(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
178
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
179 if(s->mb_num > 1583)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
180 if(get_bits1(&s->gb)==0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
181 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
182
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
183 s->qscale = get_bits(&s->gb, 5); /* SQUANT */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
184 if(get_bits1(&s->gb)==0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
185 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
186 gfid = get_bits(&s->gb, 2); /* GFID */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
187 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
188 gob_number = get_bits(&s->gb, 5); /* GN */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
189 s->mb_x= 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
190 s->mb_y= s->gob_index* gob_number;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
191 gfid = get_bits(&s->gb, 2); /* GFID */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
192 s->qscale = get_bits(&s->gb, 5); /* GQUANT */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
193 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
194
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
195 if(s->mb_y >= s->mb_height)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
196 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
197
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
198 if(s->qscale==0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
199 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
200
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
201 return 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
202 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
203
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
204 /**
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
205 * finds the next resync_marker
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
206 * @param p pointer to buffer to scan
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
207 * @param end pointer to the end of the buffer
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
208 * @return pointer to the next resync_marker, or end if none was found
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
209 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
210 const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p, const uint8_t * restrict end)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
211 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
212 assert(p < end);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
213
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
214 end-=2;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
215 p++;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
216 for(;p<end; p+=2){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
217 if(!*p){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
218 if (!p[-1] && p[1]) return p - 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
219 else if(!p[ 1] && p[2]) return p;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
220 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
221 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
222 return end+2;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
223 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
224
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
225 /**
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
226 * decodes the group of blocks / video packet header.
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
227 * @return bit position of the resync_marker, or <0 if none was found
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
228 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
229 int ff_h263_resync(MpegEncContext *s){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
230 int left, pos, ret;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
231
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
232 if(s->codec_id==CODEC_ID_MPEG4){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
233 skip_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
234 align_get_bits(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
235 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
236
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
237 if(show_bits(&s->gb, 16)==0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
238 pos= get_bits_count(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
239 if(CONFIG_MPEG4_DECODER && s->codec_id==CODEC_ID_MPEG4)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
240 ret= mpeg4_decode_video_packet_header(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
241 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
242 ret= h263_decode_gob_header(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
243 if(ret>=0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
244 return pos;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
245 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
246 //OK, it's not where it is supposed to be ...
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
247 s->gb= s->last_resync_gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
248 align_get_bits(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
249 left= get_bits_left(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
250
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
251 for(;left>16+1+5+5; left-=8){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
252 if(show_bits(&s->gb, 16)==0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
253 GetBitContext bak= s->gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
254
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
255 pos= get_bits_count(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
256 if(CONFIG_MPEG4_DECODER && s->codec_id==CODEC_ID_MPEG4)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
257 ret= mpeg4_decode_video_packet_header(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
258 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
259 ret= h263_decode_gob_header(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
260 if(ret>=0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
261 return pos;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
262
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
263 s->gb= bak;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
264 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
265 skip_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
266 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
267
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
268 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
269 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
270
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
271 int h263_decode_motion(MpegEncContext * s, int pred, int f_code)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
272 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
273 int code, val, sign, shift, l;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
274 code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
275
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
276 if (code == 0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
277 return pred;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
278 if (code < 0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
279 return 0xffff;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
280
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
281 sign = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
282 shift = f_code - 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
283 val = code;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
284 if (shift) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
285 val = (val - 1) << shift;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
286 val |= get_bits(&s->gb, shift);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
287 val++;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
288 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
289 if (sign)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
290 val = -val;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
291 val += pred;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
292
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
293 /* modulo decoding */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
294 if (!s->h263_long_vectors) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
295 l = INT_BIT - 5 - f_code;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
296 val = (val<<l)>>l;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
297 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
298 /* horrible h263 long vector mode */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
299 if (pred < -31 && val < -63)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
300 val += 64;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
301 if (pred > 32 && val > 63)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
302 val -= 64;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
303
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
304 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
305 return val;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
306 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
307
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
308
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
309 /* Decodes RVLC of H.263+ UMV */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
310 static int h263p_decode_umotion(MpegEncContext * s, int pred)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
311 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
312 int code = 0, sign;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
313
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
314 if (get_bits1(&s->gb)) /* Motion difference = 0 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
315 return pred;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
316
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
317 code = 2 + get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
318
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
319 while (get_bits1(&s->gb))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
320 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
321 code <<= 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
322 code += get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
323 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
324 sign = code & 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
325 code >>= 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
326
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
327 code = (sign) ? (pred - code) : (pred + code);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
328 dprintf(s->avctx,"H.263+ UMV Motion = %d\n", code);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
329 return code;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
330
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
331 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
332
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
333 /**
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
334 * read the next MVs for OBMC. yes this is a ugly hack, feel free to send a patch :)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
335 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
336 static void preview_obmc(MpegEncContext *s){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
337 GetBitContext gb= s->gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
338
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
339 int cbpc, i, pred_x, pred_y, mx, my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
340 int16_t *mot_val;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
341 const int xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
342 const int stride= s->b8_stride*2;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
343
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
344 for(i=0; i<4; i++)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
345 s->block_index[i]+= 2;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
346 for(i=4; i<6; i++)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
347 s->block_index[i]+= 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
348 s->mb_x++;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
349
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
350 assert(s->pict_type == FF_P_TYPE);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
351
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
352 do{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
353 if (get_bits1(&s->gb)) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
354 /* skip mb */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
355 mot_val = s->current_picture.motion_val[0][ s->block_index[0] ];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
356 mot_val[0 ]= mot_val[2 ]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
357 mot_val[0+stride]= mot_val[2+stride]= 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
358 mot_val[1 ]= mot_val[3 ]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
359 mot_val[1+stride]= mot_val[3+stride]= 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
360
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
361 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
362 goto end;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
363 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
364 cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
365 }while(cbpc == 20);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
366
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
367 if(cbpc & 4){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
368 s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
369 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
370 get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
371 if (cbpc & 8) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
372 if(s->modified_quant){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
373 if(get_bits1(&s->gb)) skip_bits(&s->gb, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
374 else skip_bits(&s->gb, 5);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
375 }else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
376 skip_bits(&s->gb, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
377 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
378
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
379 if ((cbpc & 16) == 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
380 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
381 /* 16x16 motion prediction */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
382 mot_val= h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
383 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
384 mx = h263p_decode_umotion(s, pred_x);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
385 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
386 mx = h263_decode_motion(s, pred_x, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
387
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
388 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
389 my = h263p_decode_umotion(s, pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
390 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
391 my = h263_decode_motion(s, pred_y, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
392
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
393 mot_val[0 ]= mot_val[2 ]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
394 mot_val[0+stride]= mot_val[2+stride]= mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
395 mot_val[1 ]= mot_val[3 ]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
396 mot_val[1+stride]= mot_val[3+stride]= my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
397 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
398 s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
399 for(i=0;i<4;i++) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
400 mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
401 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
402 mx = h263p_decode_umotion(s, pred_x);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
403 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
404 mx = h263_decode_motion(s, pred_x, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
405
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
406 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
407 my = h263p_decode_umotion(s, pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
408 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
409 my = h263_decode_motion(s, pred_y, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
410 if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
411 skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
412 mot_val[0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
413 mot_val[1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
414 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
415 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
416 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
417 end:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
418
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
419 for(i=0; i<4; i++)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
420 s->block_index[i]-= 2;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
421 for(i=4; i<6; i++)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
422 s->block_index[i]-= 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
423 s->mb_x--;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
424
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
425 s->gb= gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
426 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
427
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
428 static void h263_decode_dquant(MpegEncContext *s){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
429 static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
430
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
431 if(s->modified_quant){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
432 if(get_bits1(&s->gb))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
433 s->qscale= modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
434 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
435 s->qscale= get_bits(&s->gb, 5);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
436 }else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
437 s->qscale += quant_tab[get_bits(&s->gb, 2)];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
438 ff_set_qscale(s, s->qscale);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
439 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
440
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
441 static int h263_decode_block(MpegEncContext * s, DCTELEM * block,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
442 int n, int coded)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
443 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
444 int code, level, i, j, last, run;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
445 RLTable *rl = &ff_h263_rl_inter;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
446 const uint8_t *scan_table;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
447 GetBitContext gb= s->gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
448
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
449 scan_table = s->intra_scantable.permutated;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
450 if (s->h263_aic && s->mb_intra) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
451 rl = &rl_intra_aic;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
452 i = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
453 if (s->ac_pred) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
454 if (s->h263_aic_dir)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
455 scan_table = s->intra_v_scantable.permutated; /* left */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
456 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
457 scan_table = s->intra_h_scantable.permutated; /* top */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
458 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
459 } else if (s->mb_intra) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
460 /* DC coef */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
461 if(s->codec_id == CODEC_ID_RV10){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
462 #if CONFIG_RV10_DECODER
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
463 if (s->rv10_version == 3 && s->pict_type == FF_I_TYPE) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
464 int component, diff;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
465 component = (n <= 3 ? 0 : n - 4 + 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
466 level = s->last_dc[component];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
467 if (s->rv10_first_dc_coded[component]) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
468 diff = rv_decode_dc(s, n);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
469 if (diff == 0xffff)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
470 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
471 level += diff;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
472 level = level & 0xff; /* handle wrap round */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
473 s->last_dc[component] = level;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
474 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
475 s->rv10_first_dc_coded[component] = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
476 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
477 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
478 level = get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
479 if (level == 255)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
480 level = 128;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
481 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
482 #endif
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
483 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
484 level = get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
485 if((level&0x7F) == 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
486 av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
487 if(s->error_recognition >= FF_ER_COMPLIANT)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
488 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
489 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
490 if (level == 255)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
491 level = 128;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
492 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
493 block[0] = level;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
494 i = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
495 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
496 i = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
497 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
498 if (!coded) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
499 if (s->mb_intra && s->h263_aic)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
500 goto not_coded;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
501 s->block_last_index[n] = i - 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
502 return 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
503 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
504 retry:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
505 for(;;) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
506 code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
507 if (code < 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
508 av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
509 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
510 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
511 if (code == rl->n) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
512 /* escape */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
513 if (CONFIG_FLV_DECODER && s->h263_flv > 1) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
514 ff_flv2_decode_ac_esc(&s->gb, &level, &run, &last);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
515 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
516 last = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
517 run = get_bits(&s->gb, 6);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
518 level = (int8_t)get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
519 if(level == -128){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
520 if (s->codec_id == CODEC_ID_RV10) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
521 /* XXX: should patch encoder too */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
522 level = get_sbits(&s->gb, 12);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
523 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
524 level = get_bits(&s->gb, 5);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
525 level |= get_sbits(&s->gb, 6)<<5;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
526 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
527 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
528 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
529 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
530 run = rl->table_run[code];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
531 level = rl->table_level[code];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
532 last = code >= rl->last;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
533 if (get_bits1(&s->gb))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
534 level = -level;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
535 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
536 i += run;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
537 if (i >= 64){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
538 if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
539 //Looks like a hack but no, it's the way it is supposed to work ...
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
540 rl = &rl_intra_aic;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
541 i = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
542 s->gb= gb;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
543 s->dsp.clear_block(block);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
544 goto retry;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
545 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
546 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
547 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
548 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
549 j = scan_table[i];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
550 block[j] = level;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
551 if (last)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
552 break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
553 i++;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
554 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
555 not_coded:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
556 if (s->mb_intra && s->h263_aic) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
557 h263_pred_acdc(s, block, n);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
558 i = 63;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
559 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
560 s->block_last_index[n] = i;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
561 return 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
562 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
563
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
564 static int h263_skip_b_part(MpegEncContext *s, int cbp)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
565 {
10961
34a65026fa06 Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents: 10828
diff changeset
566 DECLARE_ALIGNED(16, DCTELEM, dblock)[64];
10828
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
567 int i, mbi;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
568
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
569 /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
570 * but real value should be restored in order to be used later (in OBMC condition)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
571 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
572 mbi = s->mb_intra;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
573 s->mb_intra = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
574 for (i = 0; i < 6; i++) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
575 if (h263_decode_block(s, dblock, i, cbp&32) < 0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
576 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
577 cbp+=cbp;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
578 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
579 s->mb_intra = mbi;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
580 return 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
581 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
582
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
583 static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
584 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
585 int c, mv = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
586
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
587 if (pb_frame < 3) { // h.263 Annex G and i263 PB-frame
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
588 c = get_bits1(gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
589 if (pb_frame == 2 && c)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
590 mv = !get_bits1(gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
591 } else { // h.263 Annex M improved PB-frame
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
592 mv = get_unary(gb, 0, 4) + 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
593 c = mv & 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
594 mv = !!(mv & 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
595 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
596 if(c)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
597 *cbpb = get_bits(gb, 6);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
598 return mv;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
599 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
600
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
601 int ff_h263_decode_mb(MpegEncContext *s,
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
602 DCTELEM block[6][64])
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
603 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
604 int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
605 int16_t *mot_val;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
606 const int xy= s->mb_x + s->mb_y * s->mb_stride;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
607 int cbpb = 0, pb_mv_count = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
608
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
609 assert(!s->h263_pred);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
610
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
611 if (s->pict_type == FF_P_TYPE) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
612 do{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
613 if (get_bits1(&s->gb)) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
614 /* skip mb */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
615 s->mb_intra = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
616 for(i=0;i<6;i++)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
617 s->block_last_index[i] = -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
618 s->mv_dir = MV_DIR_FORWARD;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
619 s->mv_type = MV_TYPE_16X16;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
620 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
621 s->mv[0][0][0] = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
622 s->mv[0][0][1] = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
623 s->mb_skipped = !(s->obmc | s->loop_filter);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
624 goto end;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
625 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
626 cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
627 if (cbpc < 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
628 av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
629 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
630 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
631 }while(cbpc == 20);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
632
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
633 s->dsp.clear_blocks(s->block[0]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
634
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
635 dquant = cbpc & 8;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
636 s->mb_intra = ((cbpc & 4) != 0);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
637 if (s->mb_intra) goto intra;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
638
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
639 if(s->pb_frame && get_bits1(&s->gb))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
640 pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
641 cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
642
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
643 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
644 cbpy ^= 0xF;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
645
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
646 cbp = (cbpc & 3) | (cbpy << 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
647 if (dquant) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
648 h263_decode_dquant(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
649 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
650
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
651 s->mv_dir = MV_DIR_FORWARD;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
652 if ((cbpc & 16) == 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
653 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
654 /* 16x16 motion prediction */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
655 s->mv_type = MV_TYPE_16X16;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
656 h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
657 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
658 mx = h263p_decode_umotion(s, pred_x);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
659 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
660 mx = h263_decode_motion(s, pred_x, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
661
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
662 if (mx >= 0xffff)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
663 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
664
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
665 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
666 my = h263p_decode_umotion(s, pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
667 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
668 my = h263_decode_motion(s, pred_y, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
669
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
670 if (my >= 0xffff)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
671 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
672 s->mv[0][0][0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
673 s->mv[0][0][1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
674
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
675 if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
676 skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
677 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
678 s->current_picture.mb_type[xy]= MB_TYPE_8x8 | MB_TYPE_L0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
679 s->mv_type = MV_TYPE_8X8;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
680 for(i=0;i<4;i++) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
681 mot_val = h263_pred_motion(s, i, 0, &pred_x, &pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
682 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
683 mx = h263p_decode_umotion(s, pred_x);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
684 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
685 mx = h263_decode_motion(s, pred_x, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
686 if (mx >= 0xffff)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
687 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
688
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
689 if (s->umvplus)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
690 my = h263p_decode_umotion(s, pred_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
691 else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
692 my = h263_decode_motion(s, pred_y, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
693 if (my >= 0xffff)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
694 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
695 s->mv[0][i][0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
696 s->mv[0][i][1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
697 if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
698 skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
699 mot_val[0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
700 mot_val[1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
701 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
702 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
703 } else if(s->pict_type==FF_B_TYPE) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
704 int mb_type;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
705 const int stride= s->b8_stride;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
706 int16_t *mot_val0 = s->current_picture.motion_val[0][ 2*(s->mb_x + s->mb_y*stride) ];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
707 int16_t *mot_val1 = s->current_picture.motion_val[1][ 2*(s->mb_x + s->mb_y*stride) ];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
708 // const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
709
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
710 //FIXME ugly
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
711 mot_val0[0 ]= mot_val0[2 ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
712 mot_val0[1 ]= mot_val0[3 ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
713 mot_val1[0 ]= mot_val1[2 ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
714 mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
715
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
716 do{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
717 mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
718 if (mb_type < 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
719 av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
720 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
721 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
722
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
723 mb_type= h263_mb_type_b_map[ mb_type ];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
724 }while(!mb_type);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
725
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
726 s->mb_intra = IS_INTRA(mb_type);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
727 if(HAS_CBP(mb_type)){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
728 s->dsp.clear_blocks(s->block[0]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
729 cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
730 if(s->mb_intra){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
731 dquant = IS_QUANT(mb_type);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
732 goto intra;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
733 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
734
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
735 cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
736
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
737 if (cbpy < 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
738 av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
739 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
740 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
741
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
742 if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
743 cbpy ^= 0xF;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
744
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
745 cbp = (cbpc & 3) | (cbpy << 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
746 }else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
747 cbp=0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
748
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
749 assert(!s->mb_intra);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
750
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
751 if(IS_QUANT(mb_type)){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
752 h263_decode_dquant(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
753 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
754
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
755 if(IS_DIRECT(mb_type)){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
756 s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
757 mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
758 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
759 s->mv_dir = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
760 s->mv_type= MV_TYPE_16X16;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
761 //FIXME UMV
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
762
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
763 if(USES_LIST(mb_type, 0)){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
764 int16_t *mot_val= h263_pred_motion(s, 0, 0, &mx, &my);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
765 s->mv_dir = MV_DIR_FORWARD;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
766
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
767 mx = h263_decode_motion(s, mx, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
768 my = h263_decode_motion(s, my, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
769
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
770 s->mv[0][0][0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
771 s->mv[0][0][1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
772 mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
773 mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
774 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
775
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
776 if(USES_LIST(mb_type, 1)){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
777 int16_t *mot_val= h263_pred_motion(s, 0, 1, &mx, &my);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
778 s->mv_dir |= MV_DIR_BACKWARD;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
779
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
780 mx = h263_decode_motion(s, mx, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
781 my = h263_decode_motion(s, my, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
782
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
783 s->mv[1][0][0] = mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
784 s->mv[1][0][1] = my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
785 mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
786 mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
787 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
788 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
789
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
790 s->current_picture.mb_type[xy]= mb_type;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
791 } else { /* I-Frame */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
792 do{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
793 cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
794 if (cbpc < 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
795 av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
796 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
797 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
798 }while(cbpc == 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
799
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
800 s->dsp.clear_blocks(s->block[0]);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
801
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
802 dquant = cbpc & 4;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
803 s->mb_intra = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
804 intra:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
805 s->current_picture.mb_type[xy]= MB_TYPE_INTRA;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
806 if (s->h263_aic) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
807 s->ac_pred = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
808 if(s->ac_pred){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
809 s->current_picture.mb_type[xy]= MB_TYPE_INTRA | MB_TYPE_ACPRED;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
810
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
811 s->h263_aic_dir = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
812 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
813 }else
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
814 s->ac_pred = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
815
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
816 if(s->pb_frame && get_bits1(&s->gb))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
817 pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
818 cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
819 if(cbpy<0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
820 av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
821 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
822 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
823 cbp = (cbpc & 3) | (cbpy << 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
824 if (dquant) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
825 h263_decode_dquant(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
826 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
827
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
828 pb_mv_count += !!s->pb_frame;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
829 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
830
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
831 while(pb_mv_count--){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
832 h263_decode_motion(s, 0, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
833 h263_decode_motion(s, 0, 1);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
834 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
835
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
836 /* decode each block */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
837 for (i = 0; i < 6; i++) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
838 if (h263_decode_block(s, block[i], i, cbp&32) < 0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
839 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
840 cbp+=cbp;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
841 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
842
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
843 if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
844 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
845 if(s->obmc && !s->mb_intra){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
846 if(s->pict_type == FF_P_TYPE && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
847 preview_obmc(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
848 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
849 end:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
850
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
851 /* per-MB end of slice check */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
852 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
853 int v= show_bits(&s->gb, 16);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
854
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
855 if(get_bits_count(&s->gb) + 16 > s->gb.size_in_bits){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
856 v>>= get_bits_count(&s->gb) + 16 - s->gb.size_in_bits;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
857 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
858
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
859 if(v==0)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
860 return SLICE_END;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
861 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
862
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
863 return SLICE_OK;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
864 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
865
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
866 /* most is hardcoded. should extend to handle all h263 streams */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
867 int h263_decode_picture_header(MpegEncContext *s)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
868 {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
869 int format, width, height, i;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
870 uint32_t startcode;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
871
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
872 align_get_bits(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
873
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
874 startcode= get_bits(&s->gb, 22-8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
875
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
876 for(i= get_bits_left(&s->gb); i>24; i-=8) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
877 startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
878
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
879 if(startcode == 0x20)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
880 break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
881 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
882
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
883 if (startcode != 0x20) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
884 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
885 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
886 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
887 /* temporal reference */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
888 i = get_bits(&s->gb, 8); /* picture timestamp */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
889 if( (s->picture_number&~0xFF)+i < s->picture_number)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
890 i+= 256;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
891 s->current_picture_ptr->pts=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
892 s->picture_number= (s->picture_number&~0xFF) + i;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
893
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
894 /* PTYPE starts here */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
895 if (get_bits1(&s->gb) != 1) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
896 /* marker */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
897 av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
898 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
899 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
900 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
901 av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
902 return -1; /* h263 id */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
903 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
904 skip_bits1(&s->gb); /* split screen off */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
905 skip_bits1(&s->gb); /* camera off */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
906 skip_bits1(&s->gb); /* freeze picture release off */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
907
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
908 format = get_bits(&s->gb, 3);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
909 /*
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
910 0 forbidden
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
911 1 sub-QCIF
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
912 10 QCIF
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
913 7 extended PTYPE (PLUSPTYPE)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
914 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
915
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
916 if (format != 7 && format != 6) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
917 s->h263_plus = 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
918 /* H.263v1 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
919 width = h263_format[format][0];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
920 height = h263_format[format][1];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
921 if (!width)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
922 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
923
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
924 s->pict_type = FF_I_TYPE + get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
925
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
926 s->h263_long_vectors = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
927
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
928 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
929 av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
930 return -1; /* SAC: off */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
931 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
932 s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
933 s->unrestricted_mv = s->h263_long_vectors || s->obmc;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
934
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
935 s->pb_frame = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
936 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
937 skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
938
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
939 s->width = width;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
940 s->height = height;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
941 s->avctx->sample_aspect_ratio= (AVRational){12,11};
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
942 s->avctx->time_base= (AVRational){1001, 30000};
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
943 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
944 int ufep;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
945
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
946 /* H.263v2 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
947 s->h263_plus = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
948 ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
949
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
950 /* ufep other than 0 and 1 are reserved */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
951 if (ufep == 1) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
952 /* OPPTYPE */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
953 format = get_bits(&s->gb, 3);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
954 dprintf(s->avctx, "ufep=1, format: %d\n", format);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
955 s->custom_pcf= get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
956 s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
957 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
958 av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
959 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
960 s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
961 s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
962 s->loop_filter= get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
963 s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
964
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
965 s->h263_slice_structured= get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
966 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
967 av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
968 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
969 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
970 av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
971 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
972 s->alt_inter_vlc= get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
973 s->modified_quant= get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
974 if(s->modified_quant)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
975 s->chroma_qscale_table= ff_h263_chroma_qscale_table;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
976
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
977 skip_bits(&s->gb, 1); /* Prevent start code emulation */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
978
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
979 skip_bits(&s->gb, 3); /* Reserved */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
980 } else if (ufep != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
981 av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
982 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
983 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
984
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
985 /* MPPTYPE */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
986 s->pict_type = get_bits(&s->gb, 3);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
987 switch(s->pict_type){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
988 case 0: s->pict_type= FF_I_TYPE;break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
989 case 1: s->pict_type= FF_P_TYPE;break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
990 case 2: s->pict_type= FF_P_TYPE;s->pb_frame = 3;break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
991 case 3: s->pict_type= FF_B_TYPE;break;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
992 case 7: s->pict_type= FF_I_TYPE;break; //ZYGO
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
993 default:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
994 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
995 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
996 skip_bits(&s->gb, 2);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
997 s->no_rounding = get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
998 skip_bits(&s->gb, 4);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
999
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1000 /* Get the picture dimensions */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1001 if (ufep) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1002 if (format == 6) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1003 /* Custom Picture Format (CPFMT) */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1004 s->aspect_ratio_info = get_bits(&s->gb, 4);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1005 dprintf(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1006 /* aspect ratios:
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1007 0 - forbidden
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1008 1 - 1:1
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1009 2 - 12:11 (CIF 4:3)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1010 3 - 10:11 (525-type 4:3)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1011 4 - 16:11 (CIF 16:9)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1012 5 - 40:33 (525-type 16:9)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1013 6-14 - reserved
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1014 */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1015 width = (get_bits(&s->gb, 9) + 1) * 4;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1016 skip_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1017 height = get_bits(&s->gb, 9) * 4;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1018 dprintf(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1019 if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1020 /* aspected dimensions */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1021 s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1022 s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1023 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1024 s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1025 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1026 } else {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1027 width = h263_format[format][0];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1028 height = h263_format[format][1];
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1029 s->avctx->sample_aspect_ratio= (AVRational){12,11};
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1030 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1031 if ((width == 0) || (height == 0))
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1032 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1033 s->width = width;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1034 s->height = height;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1035
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1036 if(s->custom_pcf){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1037 int gcd;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1038 s->avctx->time_base.den= 1800000;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1039 s->avctx->time_base.num= 1000 + get_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1040 s->avctx->time_base.num*= get_bits(&s->gb, 7);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1041 if(s->avctx->time_base.num == 0){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1042 av_log(s, AV_LOG_ERROR, "zero framerate\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1043 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1044 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1045 gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1046 s->avctx->time_base.den /= gcd;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1047 s->avctx->time_base.num /= gcd;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1048 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1049 s->avctx->time_base= (AVRational){1001, 30000};
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1050 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1051 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1052
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1053 if(s->custom_pcf){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1054 skip_bits(&s->gb, 2); //extended Temporal reference
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1055 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1056
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1057 if (ufep) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1058 if (s->umvplus) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1059 if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1060 skip_bits1(&s->gb);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1061 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1062 if(s->h263_slice_structured){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1063 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1064 av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1065 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1066 if (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1067 av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1068 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1069 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1070 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1071
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1072 s->qscale = get_bits(&s->gb, 5);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1073 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1074
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1075 s->mb_width = (s->width + 15) / 16;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1076 s->mb_height = (s->height + 15) / 16;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1077 s->mb_num = s->mb_width * s->mb_height;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1078
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1079 if (s->pb_frame) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1080 skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1081 if (s->custom_pcf)
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1082 skip_bits(&s->gb, 2); //extended Temporal reference
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1083 skip_bits(&s->gb, 2); /* Quantization information for B-pictures */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1084 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1085
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1086 /* PEI */
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1087 while (get_bits1(&s->gb) != 0) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1088 skip_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1089 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1090
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1091 if(s->h263_slice_structured){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1092 if (get_bits1(&s->gb) != 1) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1093 av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1094 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1095 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1096
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1097 ff_h263_decode_mba(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1098
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1099 if (get_bits1(&s->gb) != 1) {
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1100 av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1101 return -1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1102 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1103 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1104 s->f_code = 1;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1105
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1106 if(s->h263_aic){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1107 s->y_dc_scale_table=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1108 s->c_dc_scale_table= ff_aic_dc_scale_table;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1109 }else{
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1110 s->y_dc_scale_table=
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1111 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1112 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1113
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1114 ff_h263_show_pict_info(s);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1115 if (s->pict_type == FF_I_TYPE && s->codec_tag == AV_RL32("ZYGO")){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1116 int i,j;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1117 for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1118 av_log(s->avctx, AV_LOG_DEBUG, "\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1119 for(i=0; i<13; i++){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1120 for(j=0; j<3; j++){
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1121 int v= get_bits(&s->gb, 8);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1122 v |= get_sbits(&s->gb, 8)<<8;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1123 av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1124 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1125 av_log(s->avctx, AV_LOG_DEBUG, "\n");
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1126 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1127 for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1128 }
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1129
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1130 return 0;
d0657e337f91 Split H263 encoder and decoder from common code.
michael
parents:
diff changeset
1131 }