2 * ITU H.263 bitstream decoder
3 * Copyright (c) 2000,2001 Fabrice Bellard
5 * Copyright (c) 2001 Juan J. Sierralta P
6 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
8 * This file is part of FFmpeg.
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #define UNCHECKED_BITSTREAM_READER 1
32 #include "config_components.h"
34 #include "libavutil/attributes.h"
35 #include "libavutil/imgutils.h"
36 #include "libavutil/internal.h"
37 #include "libavutil/mathematics.h"
38 #include "libavutil/mem_internal.h"
39 #include "libavutil/thread.h"
41 #include "mpegvideo.h"
46 #include "mpegutils.h"
49 #include "mpeg4video.h"
50 #include "mpegvideodata.h"
51 #include "mpegvideodec.h"
52 #include "mpeg4videodec.h"
53 #include "mpeg4videodefs.h"
55 // The defines below define the number of bits that are read at once for
56 // reading vlc values. Changing these may improve speed and data cache needs
57 // be aware though that decreasing them may need the number of stages that is
58 // passed to get_vlc* to be increased.
59 #define H263_MBTYPE_B_VLC_BITS 6
60 #define CBPC_B_VLC_BITS 3
62 static const int16_t h263_mb_type_b_map
[15]= {
63 MB_TYPE_DIRECT2
| MB_TYPE_BIDIR_MV
,
64 MB_TYPE_DIRECT2
| MB_TYPE_BIDIR_MV
| MB_TYPE_CBP
,
65 MB_TYPE_DIRECT2
| MB_TYPE_BIDIR_MV
| MB_TYPE_CBP
| MB_TYPE_QUANT
,
66 MB_TYPE_FORWARD_MV
| MB_TYPE_16x16
,
67 MB_TYPE_FORWARD_MV
| MB_TYPE_CBP
| MB_TYPE_16x16
,
68 MB_TYPE_FORWARD_MV
| MB_TYPE_CBP
| MB_TYPE_QUANT
| MB_TYPE_16x16
,
69 MB_TYPE_BACKWARD_MV
| MB_TYPE_16x16
,
70 MB_TYPE_BACKWARD_MV
| MB_TYPE_CBP
| MB_TYPE_16x16
,
71 MB_TYPE_BACKWARD_MV
| MB_TYPE_CBP
| MB_TYPE_QUANT
| MB_TYPE_16x16
,
72 MB_TYPE_BIDIR_MV
| MB_TYPE_16x16
,
73 MB_TYPE_BIDIR_MV
| MB_TYPE_CBP
| MB_TYPE_16x16
,
74 MB_TYPE_BIDIR_MV
| MB_TYPE_CBP
| MB_TYPE_QUANT
| MB_TYPE_16x16
,
76 MB_TYPE_INTRA4x4
| MB_TYPE_CBP
,
77 MB_TYPE_INTRA4x4
| MB_TYPE_CBP
| MB_TYPE_QUANT
,
80 void ff_h263_show_pict_info(MpegEncContext
*s
){
81 if(s
->avctx
->debug
&FF_DEBUG_PICT_INFO
){
82 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",
83 s
->qscale
, av_get_picture_type_char(s
->pict_type
),
84 s
->gb
.size_in_bits
, 1-s
->no_rounding
,
86 s
->umvplus
? " UMV" : "",
87 s
->h263_long_vectors
? " LONG" : "",
88 s
->h263_plus
? " +" : "",
89 s
->h263_aic
? " AIC" : "",
90 s
->alt_inter_vlc
? " AIV" : "",
91 s
->modified_quant
? " MQ" : "",
92 s
->loop_filter
? " LOOP" : "",
93 s
->h263_slice_structured
? " SS" : "",
94 s
->avctx
->framerate
.num
, s
->avctx
->framerate
.den
99 /***********************************************/
102 VLCElem ff_h263_intra_MCBPC_vlc
[72];
103 VLCElem ff_h263_inter_MCBPC_vlc
[198];
104 VLCElem ff_h263_cbpy_vlc
[64];
105 VLCElem ff_h263_mv_vlc
[538];
106 static VLCElem h263_mbtype_b_vlc
[80];
107 static VLCElem cbpc_b_vlc
[8];
111 static av_cold
void h263_decode_init_vlc(void)
113 VLC_INIT_STATIC_TABLE(ff_h263_intra_MCBPC_vlc
, INTRA_MCBPC_VLC_BITS
, 9,
114 ff_h263_intra_MCBPC_bits
, 1, 1,
115 ff_h263_intra_MCBPC_code
, 1, 1, 0);
116 VLC_INIT_STATIC_TABLE(ff_h263_inter_MCBPC_vlc
, INTER_MCBPC_VLC_BITS
, 28,
117 ff_h263_inter_MCBPC_bits
, 1, 1,
118 ff_h263_inter_MCBPC_code
, 1, 1, 0);
119 VLC_INIT_STATIC_TABLE(ff_h263_cbpy_vlc
, CBPY_VLC_BITS
, 16,
120 &ff_h263_cbpy_tab
[0][1], 2, 1,
121 &ff_h263_cbpy_tab
[0][0], 2, 1, 0);
122 VLC_INIT_STATIC_TABLE(ff_h263_mv_vlc
, H263_MV_VLC_BITS
, 33,
123 &ff_mvtab
[0][1], 2, 1,
124 &ff_mvtab
[0][0], 2, 1, 0);
125 ff_h263_init_rl_inter();
126 VLC_INIT_RL(ff_h263_rl_inter
, 554);
127 INIT_FIRST_VLC_RL(ff_rl_intra_aic
, 554);
128 VLC_INIT_STATIC_SPARSE_TABLE(h263_mbtype_b_vlc
, H263_MBTYPE_B_VLC_BITS
, 15,
129 &ff_h263_mbtype_b_tab
[0][1], 2, 1,
130 &ff_h263_mbtype_b_tab
[0][0], 2, 1,
131 h263_mb_type_b_map
, 2, 2, 0);
132 VLC_INIT_STATIC_TABLE(cbpc_b_vlc
, CBPC_B_VLC_BITS
, 4,
133 &ff_cbpc_b_tab
[0][1], 2, 1,
134 &ff_cbpc_b_tab
[0][0], 2, 1, 0);
137 av_cold
void ff_h263_decode_init_vlc(void)
139 static AVOnce init_static_once
= AV_ONCE_INIT
;
140 ff_thread_once(&init_static_once
, h263_decode_init_vlc
);
143 int ff_h263_decode_mba(MpegEncContext
*s
)
147 for (i
= 0; i
< 6; i
++)
148 if (s
->mb_num
- 1 <= ff_mba_max
[i
])
150 mb_pos
= get_bits(&s
->gb
, ff_mba_length
[i
]);
151 s
->mb_x
= mb_pos
% s
->mb_width
;
152 s
->mb_y
= mb_pos
/ s
->mb_width
;
158 * Decode the group of blocks header or slice header.
159 * @return <0 if an error occurred
161 static int h263_decode_gob_header(MpegEncContext
*s
)
163 unsigned int val
, gob_number
;
166 /* Check for GOB Start Code */
167 val
= show_bits(&s
->gb
, 16);
171 /* We have a GBSC probably with GSTUFF */
172 skip_bits(&s
->gb
, 16); /* Drop the zeros */
173 left
= get_bits_left(&s
->gb
);
174 left
= FFMIN(left
, 32);
175 //MN: we must check the bits left or we might end in an infinite loop (or segfault)
176 for(;left
>13; left
--){
177 if(get_bits1(&s
->gb
)) break; /* Seek the '1' bit */
182 if(s
->h263_slice_structured
){
183 if(check_marker(s
->avctx
, &s
->gb
, "before MBA")==0)
186 ff_h263_decode_mba(s
);
189 if(check_marker(s
->avctx
, &s
->gb
, "after MBA")==0)
192 s
->qscale
= get_bits(&s
->gb
, 5); /* SQUANT */
193 if(check_marker(s
->avctx
, &s
->gb
, "after SQUANT")==0)
195 skip_bits(&s
->gb
, 2); /* GFID */
197 gob_number
= get_bits(&s
->gb
, 5); /* GN */
199 s
->mb_y
= s
->gob_index
* gob_number
;
200 skip_bits(&s
->gb
, 2); /* GFID */
201 s
->qscale
= get_bits(&s
->gb
, 5); /* GQUANT */
204 if(s
->mb_y
>= s
->mb_height
)
214 * Decode the group of blocks / video packet header / slice header (MPEG-4 Studio).
215 * @return bit position of the resync_marker, or <0 if none was found
217 int ff_h263_resync(MpegEncContext
*s
){
220 /* In MPEG-4 studio mode look for a new slice startcode
221 * and decode slice header */
222 if(s
->codec_id
==AV_CODEC_ID_MPEG4
&& s
->studio_profile
) {
223 align_get_bits(&s
->gb
);
225 while (get_bits_left(&s
->gb
) >= 32 && show_bits_long(&s
->gb
, 32) != SLICE_STARTCODE
) {
229 if (get_bits_left(&s
->gb
) >= 32 && show_bits_long(&s
->gb
, 32) == SLICE_STARTCODE
)
230 return get_bits_count(&s
->gb
);
235 if(s
->codec_id
==AV_CODEC_ID_MPEG4
){
237 align_get_bits(&s
->gb
);
240 if(show_bits(&s
->gb
, 16)==0){
241 pos
= get_bits_count(&s
->gb
);
242 if(CONFIG_MPEG4_DECODER
&& s
->codec_id
==AV_CODEC_ID_MPEG4
)
243 ret
= ff_mpeg4_decode_video_packet_header(s
->avctx
->priv_data
);
245 ret
= h263_decode_gob_header(s
);
249 //OK, it's not where it is supposed to be ...
250 s
->gb
= s
->last_resync_gb
;
251 align_get_bits(&s
->gb
);
252 left
= get_bits_left(&s
->gb
);
254 for(;left
>16+1+5+5; left
-=8){
255 if(show_bits(&s
->gb
, 16)==0){
256 GetBitContext bak
= s
->gb
;
258 pos
= get_bits_count(&s
->gb
);
259 if(CONFIG_MPEG4_DECODER
&& s
->codec_id
==AV_CODEC_ID_MPEG4
)
260 ret
= ff_mpeg4_decode_video_packet_header(s
->avctx
->priv_data
);
262 ret
= h263_decode_gob_header(s
);
268 skip_bits(&s
->gb
, 8);
274 int ff_h263_decode_motion(MpegEncContext
* s
, int pred
, int f_code
)
276 int code
, val
, sign
, shift
;
277 code
= get_vlc2(&s
->gb
, ff_h263_mv_vlc
, H263_MV_VLC_BITS
, 2);
284 sign
= get_bits1(&s
->gb
);
288 val
= (val
- 1) << shift
;
289 val
|= get_bits(&s
->gb
, shift
);
296 /* modulo decoding */
297 if (!s
->h263_long_vectors
) {
298 val
= sign_extend(val
, 5 + f_code
);
300 /* horrible H.263 long vector mode */
301 if (pred
< -31 && val
< -63)
303 if (pred
> 32 && val
> 63)
311 /* Decode RVLC of H.263+ UMV */
312 static int h263p_decode_umotion(MpegEncContext
* s
, int pred
)
316 if (get_bits1(&s
->gb
)) /* Motion difference = 0 */
319 code
= 2 + get_bits1(&s
->gb
);
321 while (get_bits1(&s
->gb
))
324 code
+= get_bits1(&s
->gb
);
326 avpriv_request_sample(s
->avctx
, "Huge DMV");
333 code
= (sign
) ? (pred
- code
) : (pred
+ code
);
334 ff_tlog(s
->avctx
,"H.263+ UMV Motion = %d\n", code
);
340 * read the next MVs for OBMC. yes this is an ugly hack, feel free to send a patch :)
342 static void preview_obmc(MpegEncContext
*s
){
343 GetBitContext gb
= s
->gb
;
345 int cbpc
, i
, pred_x
, pred_y
, mx
, my
;
347 const int xy
= s
->mb_x
+ 1 + s
->mb_y
* s
->mb_stride
;
348 const int stride
= s
->b8_stride
*2;
351 s
->block_index
[i
]+= 2;
353 s
->block_index
[i
]+= 1;
356 av_assert2(s
->pict_type
== AV_PICTURE_TYPE_P
);
359 if (get_bits1(&s
->gb
)) {
361 mot_val
= s
->cur_pic
.motion_val
[0][s
->block_index
[0]];
362 mot_val
[0 ]= mot_val
[2 ]=
363 mot_val
[0+stride
]= mot_val
[2+stride
]= 0;
364 mot_val
[1 ]= mot_val
[3 ]=
365 mot_val
[1+stride
]= mot_val
[3+stride
]= 0;
367 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_SKIP
| MB_TYPE_16x16
| MB_TYPE_FORWARD_MV
;
370 cbpc
= get_vlc2(&s
->gb
, ff_h263_inter_MCBPC_vlc
, INTER_MCBPC_VLC_BITS
, 2);
374 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_INTRA
;
376 get_vlc2(&s
->gb
, ff_h263_cbpy_vlc
, CBPY_VLC_BITS
, 1);
378 if(s
->modified_quant
){
379 if(get_bits1(&s
->gb
)) skip_bits(&s
->gb
, 1);
380 else skip_bits(&s
->gb
, 5);
382 skip_bits(&s
->gb
, 2);
385 if ((cbpc
& 16) == 0) {
386 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_16x16
| MB_TYPE_FORWARD_MV
;
387 /* 16x16 motion prediction */
388 mot_val
= ff_h263_pred_motion(s
, 0, 0, &pred_x
, &pred_y
);
390 mx
= h263p_decode_umotion(s
, pred_x
);
392 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
395 my
= h263p_decode_umotion(s
, pred_y
);
397 my
= ff_h263_decode_motion(s
, pred_y
, 1);
399 mot_val
[0 ]= mot_val
[2 ]=
400 mot_val
[0+stride
]= mot_val
[2+stride
]= mx
;
401 mot_val
[1 ]= mot_val
[3 ]=
402 mot_val
[1+stride
]= mot_val
[3+stride
]= my
;
404 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_8x8
| MB_TYPE_FORWARD_MV
;
406 mot_val
= ff_h263_pred_motion(s
, i
, 0, &pred_x
, &pred_y
);
408 mx
= h263p_decode_umotion(s
, pred_x
);
410 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
413 my
= h263p_decode_umotion(s
, pred_y
);
415 my
= ff_h263_decode_motion(s
, pred_y
, 1);
416 if (s
->umvplus
&& (mx
- pred_x
) == 1 && (my
- pred_y
) == 1)
417 skip_bits1(&s
->gb
); /* Bit stuffing to prevent PSC */
426 s
->block_index
[i
]-= 2;
428 s
->block_index
[i
]-= 1;
434 static void h263_decode_dquant(MpegEncContext
*s
){
435 static const int8_t quant_tab
[4] = { -1, -2, 1, 2 };
437 if(s
->modified_quant
){
438 if(get_bits1(&s
->gb
))
439 s
->qscale
= ff_modified_quant_tab
[get_bits1(&s
->gb
)][ s
->qscale
];
441 s
->qscale
= get_bits(&s
->gb
, 5);
443 s
->qscale
+= quant_tab
[get_bits(&s
->gb
, 2)];
444 ff_set_qscale(s
, s
->qscale
);
447 static void h263_pred_acdc(MpegEncContext
* s
, int16_t *block
, int n
)
449 int x
, y
, wrap
, a
, c
, pred_dc
, scale
;
450 int16_t *dc_val
, *ac_val
, *ac_val1
;
452 /* find prediction */
454 x
= 2 * s
->mb_x
+ (n
& 1);
455 y
= 2 * s
->mb_y
+ (n
>> 1);
457 dc_val
= s
->dc_val
[0];
458 ac_val
= s
->ac_val
[0][0];
459 scale
= s
->y_dc_scale
;
464 dc_val
= s
->dc_val
[n
- 4 + 1];
465 ac_val
= s
->ac_val
[n
- 4 + 1][0];
466 scale
= s
->c_dc_scale
;
469 ac_val
+= ((y
) * wrap
+ (x
)) * 16;
475 a
= dc_val
[(x
- 1) + (y
) * wrap
];
476 c
= dc_val
[(x
) + (y
- 1) * wrap
];
478 /* No prediction outside GOB boundary */
479 if (s
->first_slice_line
&& n
!= 3) {
481 if (n
!= 1 && s
->mb_x
== s
->resync_mb_x
) a
= 1024;
486 if (s
->h263_aic_dir
) {
487 /* left prediction */
490 for (int i
= 1; i
< 8; i
++) {
491 block
[s
->idsp
.idct_permutation
[i
<< 3]] += ac_val
[i
];
499 for (int i
= 1; i
< 8; i
++) {
500 block
[s
->idsp
.idct_permutation
[i
]] += ac_val
[i
+ 8];
506 /* just DC prediction */
507 if (a
!= 1024 && c
!= 1024)
508 pred_dc
= (a
+ c
) >> 1;
515 /* we assume pred is positive */
516 block
[0] = block
[0] * scale
+ pred_dc
;
523 /* Update AC/DC tables */
524 dc_val
[(x
) + (y
) * wrap
] = block
[0];
527 for (int i
= 1; i
< 8; i
++)
528 ac_val1
[i
] = block
[s
->idsp
.idct_permutation
[i
<< 3]];
530 for (int i
= 1; i
< 8; i
++)
531 ac_val1
[8 + i
] = block
[s
->idsp
.idct_permutation
[i
]];
534 static int h263_decode_block(MpegEncContext
* s
, int16_t * block
,
537 int level
, i
, j
, run
;
538 const RLTable
*rl
= &ff_h263_rl_inter
;
539 const uint8_t *scan_table
;
540 GetBitContext gb
= s
->gb
;
542 scan_table
= s
->intra_scantable
.permutated
;
543 if (s
->h263_aic
&& s
->mb_intra
) {
544 rl
= &ff_rl_intra_aic
;
548 scan_table
= s
->permutated_intra_v_scantable
; /* left */
550 scan_table
= s
->permutated_intra_h_scantable
; /* top */
552 } else if (s
->mb_intra
) {
554 if (CONFIG_RV10_DECODER
&& s
->codec_id
== AV_CODEC_ID_RV10
) {
555 if (s
->rv10_version
== 3 && s
->pict_type
== AV_PICTURE_TYPE_I
) {
557 component
= (n
<= 3 ? 0 : n
- 4 + 1);
558 level
= s
->last_dc
[component
];
559 if (s
->rv10_first_dc_coded
[component
]) {
560 diff
= ff_rv_decode_dc(s
, n
);
564 level
= level
& 0xff; /* handle wrap round */
565 s
->last_dc
[component
] = level
;
567 s
->rv10_first_dc_coded
[component
] = 1;
570 level
= get_bits(&s
->gb
, 8);
575 level
= get_bits(&s
->gb
, 8);
576 if((level
&0x7F) == 0){
577 av_log(s
->avctx
, AV_LOG_ERROR
, "illegal dc %d at %d %d\n", level
, s
->mb_x
, s
->mb_y
);
578 if (s
->avctx
->err_recognition
& (AV_EF_BITSTREAM
|AV_EF_COMPLIANT
))
590 if (s
->mb_intra
&& s
->h263_aic
)
592 s
->block_last_index
[n
] = i
- 1;
597 OPEN_READER(re
, &s
->gb
);
598 i
--; // offset by -1 to allow direct indexing of scan_table
600 UPDATE_CACHE(re
, &s
->gb
);
601 GET_RL_VLC(level
, run
, re
, &s
->gb
, rl
->rl_vlc
[0], TEX_VLC_BITS
, 2, 0);
604 CLOSE_READER(re
, &s
->gb
);
605 av_log(s
->avctx
, AV_LOG_ERROR
, "illegal ac vlc code at %dx%d\n", s
->mb_x
, s
->mb_y
);
609 if (CONFIG_FLV_DECODER
&& s
->h263_flv
> 1) {
610 int is11
= SHOW_UBITS(re
, &s
->gb
, 1);
611 SKIP_CACHE(re
, &s
->gb
, 1);
612 run
= SHOW_UBITS(re
, &s
->gb
, 7) + 1;
614 SKIP_COUNTER(re
, &s
->gb
, 1 + 7);
615 UPDATE_CACHE(re
, &s
->gb
);
616 level
= SHOW_SBITS(re
, &s
->gb
, 11);
617 SKIP_COUNTER(re
, &s
->gb
, 11);
619 SKIP_CACHE(re
, &s
->gb
, 7);
620 level
= SHOW_SBITS(re
, &s
->gb
, 7);
621 SKIP_COUNTER(re
, &s
->gb
, 1 + 7 + 7);
624 run
= SHOW_UBITS(re
, &s
->gb
, 7) + 1;
625 SKIP_CACHE(re
, &s
->gb
, 7);
626 level
= (int8_t)SHOW_UBITS(re
, &s
->gb
, 8);
627 SKIP_COUNTER(re
, &s
->gb
, 7 + 8);
629 UPDATE_CACHE(re
, &s
->gb
);
630 if (s
->codec_id
== AV_CODEC_ID_RV10
) {
631 /* XXX: should patch encoder too */
632 level
= SHOW_SBITS(re
, &s
->gb
, 12);
633 SKIP_COUNTER(re
, &s
->gb
, 12);
635 level
= SHOW_UBITS(re
, &s
->gb
, 5);
636 SKIP_CACHE(re
, &s
->gb
, 5);
637 level
|= SHOW_SBITS(re
, &s
->gb
, 6) * (1<<5);
638 SKIP_COUNTER(re
, &s
->gb
, 5 + 6);
643 if (SHOW_UBITS(re
, &s
->gb
, 1))
645 SKIP_COUNTER(re
, &s
->gb
, 1);
649 CLOSE_READER(re
, &s
->gb
);
650 // redo update without last flag, revert -1 offset
651 i
= i
- run
+ ((run
-1)&63) + 1;
653 // only last marker, no overrun
654 block
[scan_table
[i
]] = level
;
657 if(s
->alt_inter_vlc
&& rl
== &ff_h263_rl_inter
&& !s
->mb_intra
){
658 //Looks like a hack but no, it's the way it is supposed to work ...
659 rl
= &ff_rl_intra_aic
;
662 s
->bdsp
.clear_block(block
);
665 av_log(s
->avctx
, AV_LOG_ERROR
, "run overflow at %dx%d i:%d\n", s
->mb_x
, s
->mb_y
, s
->mb_intra
);
673 if (s
->mb_intra
&& s
->h263_aic
) {
674 h263_pred_acdc(s
, block
, n
);
677 s
->block_last_index
[n
] = i
;
681 static int h263_skip_b_part(MpegEncContext
*s
, int cbp
)
683 LOCAL_ALIGNED_32(int16_t, dblock
, [64]);
687 /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
688 * but real value should be restored in order to be used later (in OBMC condition)
691 memcpy(bli
, s
->block_last_index
, sizeof(bli
));
693 for (i
= 0; i
< 6; i
++) {
694 if (h263_decode_block(s
, dblock
, i
, cbp
&32) < 0)
699 memcpy(s
->block_last_index
, bli
, sizeof(bli
));
703 static int h263_get_modb(GetBitContext
*gb
, int pb_frame
, int *cbpb
)
707 if (pb_frame
< 3) { // h.263 Annex G and i263 PB-frame
709 if (pb_frame
== 2 && c
)
711 } else { // h.263 Annex M improved PB-frame
712 mv
= get_unary(gb
, 0, 4) + 1;
717 *cbpb
= get_bits(gb
, 6);
721 #define tab_size ((signed)FF_ARRAY_ELEMS(s->direct_scale_mv[0]))
722 #define tab_bias (tab_size / 2)
723 static inline void set_one_direct_mv(MpegEncContext
*s
, const MPVPicture
*p
, int i
)
725 int xy
= s
->block_index
[i
];
726 uint16_t time_pp
= s
->pp_time
;
727 uint16_t time_pb
= s
->pb_time
;
730 p_mx
= p
->motion_val
[0][xy
][0];
731 if ((unsigned)(p_mx
+ tab_bias
) < tab_size
) {
732 s
->mv
[0][i
][0] = s
->direct_scale_mv
[0][p_mx
+ tab_bias
];
733 s
->mv
[1][i
][0] = s
->direct_scale_mv
[1][p_mx
+ tab_bias
];
735 s
->mv
[0][i
][0] = p_mx
* time_pb
/ time_pp
;
736 s
->mv
[1][i
][0] = p_mx
* (time_pb
- time_pp
) / time_pp
;
738 p_my
= p
->motion_val
[0][xy
][1];
739 if ((unsigned)(p_my
+ tab_bias
) < tab_size
) {
740 s
->mv
[0][i
][1] = s
->direct_scale_mv
[0][p_my
+ tab_bias
];
741 s
->mv
[1][i
][1] = s
->direct_scale_mv
[1][p_my
+ tab_bias
];
743 s
->mv
[0][i
][1] = p_my
* time_pb
/ time_pp
;
744 s
->mv
[1][i
][1] = p_my
* (time_pb
- time_pp
) / time_pp
;
749 * @return the mb_type
751 static int set_direct_mv(MpegEncContext
*s
)
753 const int mb_index
= s
->mb_x
+ s
->mb_y
* s
->mb_stride
;
754 const MPVPicture
*p
= s
->next_pic
.ptr
;
755 int colocated_mb_type
= p
->mb_type
[mb_index
];
758 if (s
->codec_tag
== AV_RL32("U263") && p
->f
->pict_type
== AV_PICTURE_TYPE_I
) {
760 colocated_mb_type
= p
->mb_type
[mb_index
];
763 if (IS_8X8(colocated_mb_type
)) {
764 s
->mv_type
= MV_TYPE_8X8
;
765 for (i
= 0; i
< 4; i
++)
766 set_one_direct_mv(s
, p
, i
);
767 return MB_TYPE_DIRECT2
| MB_TYPE_8x8
| MB_TYPE_BIDIR_MV
;
769 set_one_direct_mv(s
, p
, 0);
772 s
->mv
[0][3][0] = s
->mv
[0][0][0];
775 s
->mv
[0][3][1] = s
->mv
[0][0][1];
778 s
->mv
[1][3][0] = s
->mv
[1][0][0];
781 s
->mv
[1][3][1] = s
->mv
[1][0][1];
782 s
->mv_type
= MV_TYPE_8X8
;
783 // Note see prev line
784 return MB_TYPE_DIRECT2
| MB_TYPE_16x16
| MB_TYPE_BIDIR_MV
;
788 int ff_h263_decode_mb(MpegEncContext
*s
,
789 int16_t block
[6][64])
791 int cbpc
, cbpy
, i
, cbp
, pred_x
, pred_y
, mx
, my
, dquant
;
793 const int xy
= s
->mb_x
+ s
->mb_y
* s
->mb_stride
;
794 int cbpb
= 0, pb_mv_count
= 0;
796 av_assert2(!s
->h263_pred
);
798 if (s
->pict_type
== AV_PICTURE_TYPE_P
) {
800 if (get_bits1(&s
->gb
)) {
804 s
->block_last_index
[i
] = -1;
805 s
->mv_dir
= MV_DIR_FORWARD
;
806 s
->mv_type
= MV_TYPE_16X16
;
807 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_SKIP
| MB_TYPE_16x16
| MB_TYPE_FORWARD_MV
;
810 s
->mb_skipped
= !(s
->obmc
| s
->loop_filter
);
813 cbpc
= get_vlc2(&s
->gb
, ff_h263_inter_MCBPC_vlc
, INTER_MCBPC_VLC_BITS
, 2);
815 av_log(s
->avctx
, AV_LOG_ERROR
, "cbpc damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
820 s
->bdsp
.clear_blocks(s
->block
[0]);
823 s
->mb_intra
= ((cbpc
& 4) != 0);
824 if (s
->mb_intra
) goto intra
;
826 if(s
->pb_frame
&& get_bits1(&s
->gb
))
827 pb_mv_count
= h263_get_modb(&s
->gb
, s
->pb_frame
, &cbpb
);
828 cbpy
= get_vlc2(&s
->gb
, ff_h263_cbpy_vlc
, CBPY_VLC_BITS
, 1);
831 av_log(s
->avctx
, AV_LOG_ERROR
, "cbpy damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
835 if(s
->alt_inter_vlc
==0 || (cbpc
& 3)!=3)
838 cbp
= (cbpc
& 3) | (cbpy
<< 2);
840 h263_decode_dquant(s
);
843 s
->mv_dir
= MV_DIR_FORWARD
;
844 if ((cbpc
& 16) == 0) {
845 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_16x16
| MB_TYPE_FORWARD_MV
;
846 /* 16x16 motion prediction */
847 s
->mv_type
= MV_TYPE_16X16
;
848 ff_h263_pred_motion(s
, 0, 0, &pred_x
, &pred_y
);
850 mx
= h263p_decode_umotion(s
, pred_x
);
852 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
858 my
= h263p_decode_umotion(s
, pred_y
);
860 my
= ff_h263_decode_motion(s
, pred_y
, 1);
867 if (s
->umvplus
&& (mx
- pred_x
) == 1 && (my
- pred_y
) == 1)
868 skip_bits1(&s
->gb
); /* Bit stuffing to prevent PSC */
870 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_8x8
| MB_TYPE_FORWARD_MV
;
871 s
->mv_type
= MV_TYPE_8X8
;
873 mot_val
= ff_h263_pred_motion(s
, i
, 0, &pred_x
, &pred_y
);
875 mx
= h263p_decode_umotion(s
, pred_x
);
877 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
882 my
= h263p_decode_umotion(s
, pred_y
);
884 my
= ff_h263_decode_motion(s
, pred_y
, 1);
889 if (s
->umvplus
&& (mx
- pred_x
) == 1 && (my
- pred_y
) == 1)
890 skip_bits1(&s
->gb
); /* Bit stuffing to prevent PSC */
895 } else if(s
->pict_type
==AV_PICTURE_TYPE_B
) {
897 const int stride
= s
->b8_stride
;
898 int16_t *mot_val0
= s
->cur_pic
.motion_val
[0][2 * (s
->mb_x
+ s
->mb_y
* stride
)];
899 int16_t *mot_val1
= s
->cur_pic
.motion_val
[1][2 * (s
->mb_x
+ s
->mb_y
* stride
)];
900 // const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
903 mot_val0
[0 ]= mot_val0
[2 ]= mot_val0
[0+2*stride
]= mot_val0
[2+2*stride
]=
904 mot_val0
[1 ]= mot_val0
[3 ]= mot_val0
[1+2*stride
]= mot_val0
[3+2*stride
]=
905 mot_val1
[0 ]= mot_val1
[2 ]= mot_val1
[0+2*stride
]= mot_val1
[2+2*stride
]=
906 mot_val1
[1 ]= mot_val1
[3 ]= mot_val1
[1+2*stride
]= mot_val1
[3+2*stride
]= 0;
909 mb_type
= get_vlc2(&s
->gb
, h263_mbtype_b_vlc
,
910 H263_MBTYPE_B_VLC_BITS
, 2);
912 av_log(s
->avctx
, AV_LOG_ERROR
, "b mb_type damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
917 s
->mb_intra
= IS_INTRA(mb_type
);
918 if(HAS_CBP(mb_type
)){
919 s
->bdsp
.clear_blocks(s
->block
[0]);
920 cbpc
= get_vlc2(&s
->gb
, cbpc_b_vlc
, CBPC_B_VLC_BITS
, 1);
922 dquant
= IS_QUANT(mb_type
);
926 cbpy
= get_vlc2(&s
->gb
, ff_h263_cbpy_vlc
, CBPY_VLC_BITS
, 1);
929 av_log(s
->avctx
, AV_LOG_ERROR
, "b cbpy damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
933 if(s
->alt_inter_vlc
==0 || (cbpc
& 3)!=3)
936 cbp
= (cbpc
& 3) | (cbpy
<< 2);
940 av_assert2(!s
->mb_intra
);
942 if(IS_QUANT(mb_type
)){
943 h263_decode_dquant(s
);
946 if(IS_DIRECT(mb_type
)){
947 s
->mv_dir
= MV_DIR_FORWARD
| MV_DIR_BACKWARD
| MV_DIRECT
;
948 mb_type
|= set_direct_mv(s
);
951 s
->mv_type
= MV_TYPE_16X16
;
954 if (HAS_FORWARD_MV(mb_type
)) {
955 int16_t *mot_val
= ff_h263_pred_motion(s
, 0, 0, &pred_x
, &pred_y
);
956 s
->mv_dir
= MV_DIR_FORWARD
;
959 mx
= h263p_decode_umotion(s
, pred_x
);
961 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
966 my
= h263p_decode_umotion(s
, pred_y
);
968 my
= ff_h263_decode_motion(s
, pred_y
, 1);
972 if (s
->umvplus
&& (mx
- pred_x
) == 1 && (my
- pred_y
) == 1)
973 skip_bits1(&s
->gb
); /* Bit stuffing to prevent PSC */
977 mot_val
[0 ]= mot_val
[2 ]= mot_val
[0+2*stride
]= mot_val
[2+2*stride
]= mx
;
978 mot_val
[1 ]= mot_val
[3 ]= mot_val
[1+2*stride
]= mot_val
[3+2*stride
]= my
;
981 if (HAS_BACKWARD_MV(mb_type
)) {
982 int16_t *mot_val
= ff_h263_pred_motion(s
, 0, 1, &pred_x
, &pred_y
);
983 s
->mv_dir
|= MV_DIR_BACKWARD
;
986 mx
= h263p_decode_umotion(s
, pred_x
);
988 mx
= ff_h263_decode_motion(s
, pred_x
, 1);
993 my
= h263p_decode_umotion(s
, pred_y
);
995 my
= ff_h263_decode_motion(s
, pred_y
, 1);
999 if (s
->umvplus
&& (mx
- pred_x
) == 1 && (my
- pred_y
) == 1)
1000 skip_bits1(&s
->gb
); /* Bit stuffing to prevent PSC */
1002 s
->mv
[1][0][0] = mx
;
1003 s
->mv
[1][0][1] = my
;
1004 mot_val
[0 ]= mot_val
[2 ]= mot_val
[0+2*stride
]= mot_val
[2+2*stride
]= mx
;
1005 mot_val
[1 ]= mot_val
[3 ]= mot_val
[1+2*stride
]= mot_val
[3+2*stride
]= my
;
1009 s
->cur_pic
.mb_type
[xy
] = mb_type
;
1010 } else { /* I-Frame */
1012 cbpc
= get_vlc2(&s
->gb
, ff_h263_intra_MCBPC_vlc
, INTRA_MCBPC_VLC_BITS
, 2);
1014 av_log(s
->avctx
, AV_LOG_ERROR
, "I cbpc damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
1019 s
->bdsp
.clear_blocks(s
->block
[0]);
1024 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_INTRA
;
1026 s
->ac_pred
= get_bits1(&s
->gb
);
1028 s
->cur_pic
.mb_type
[xy
] = MB_TYPE_INTRA
| MB_TYPE_ACPRED
;
1030 s
->h263_aic_dir
= get_bits1(&s
->gb
);
1035 if(s
->pb_frame
&& get_bits1(&s
->gb
))
1036 pb_mv_count
= h263_get_modb(&s
->gb
, s
->pb_frame
, &cbpb
);
1037 cbpy
= get_vlc2(&s
->gb
, ff_h263_cbpy_vlc
, CBPY_VLC_BITS
, 1);
1039 av_log(s
->avctx
, AV_LOG_ERROR
, "I cbpy damaged at %d %d\n", s
->mb_x
, s
->mb_y
);
1042 cbp
= (cbpc
& 3) | (cbpy
<< 2);
1044 h263_decode_dquant(s
);
1047 pb_mv_count
+= !!s
->pb_frame
;
1050 while(pb_mv_count
--){
1051 ff_h263_decode_motion(s
, 0, 1);
1052 ff_h263_decode_motion(s
, 0, 1);
1055 /* decode each block */
1056 for (i
= 0; i
< 6; i
++) {
1057 if (h263_decode_block(s
, block
[i
], i
, cbp
&32) < 0)
1062 if(s
->pb_frame
&& h263_skip_b_part(s
, cbpb
) < 0)
1064 if(s
->obmc
&& !s
->mb_intra
){
1065 if(s
->pict_type
== AV_PICTURE_TYPE_P
&& s
->mb_x
+1<s
->mb_width
&& s
->mb_num_left
!= 1)
1070 if (get_bits_left(&s
->gb
) < 0)
1071 return AVERROR_INVALIDDATA
;
1073 /* per-MB end of slice check */
1075 int v
= show_bits(&s
->gb
, 16);
1077 if (get_bits_left(&s
->gb
) < 16) {
1078 v
>>= 16 - get_bits_left(&s
->gb
);
1088 /* Most is hardcoded; should extend to handle all H.263 streams. */
1089 int ff_h263_decode_picture_header(MpegEncContext
*s
)
1091 int format
, width
, height
, i
, ret
;
1094 align_get_bits(&s
->gb
);
1096 if (show_bits(&s
->gb
, 2) == 2 && s
->avctx
->frame_num
== 0) {
1097 av_log(s
->avctx
, AV_LOG_WARNING
, "Header looks like RTP instead of H.263\n");
1100 startcode
= get_bits(&s
->gb
, 22-8);
1102 for(i
= get_bits_left(&s
->gb
); i
>24; i
-=8) {
1103 startcode
= ((startcode
<< 8) | get_bits(&s
->gb
, 8)) & 0x003FFFFF;
1105 if(startcode
== 0x20)
1109 if (startcode
!= 0x20) {
1110 av_log(s
->avctx
, AV_LOG_ERROR
, "Bad picture start code\n");
1113 /* temporal reference */
1114 i
= get_bits(&s
->gb
, 8); /* picture timestamp */
1116 i
-= (i
- (s
->picture_number
& 0xFF) + 128) & ~0xFF;
1118 s
->picture_number
= (s
->picture_number
&~0xFF) + i
;
1120 /* PTYPE starts here */
1121 if (check_marker(s
->avctx
, &s
->gb
, "in PTYPE") != 1) {
1124 if (get_bits1(&s
->gb
) != 0) {
1125 av_log(s
->avctx
, AV_LOG_ERROR
, "Bad H.263 id\n");
1126 return -1; /* H.263 id */
1128 skip_bits1(&s
->gb
); /* split screen off */
1129 skip_bits1(&s
->gb
); /* camera off */
1130 skip_bits1(&s
->gb
); /* freeze picture release off */
1132 format
= get_bits(&s
->gb
, 3);
1137 7 extended PTYPE (PLUSPTYPE)
1140 if (format
!= 7 && format
!= 6) {
1143 width
= ff_h263_format
[format
][0];
1144 height
= ff_h263_format
[format
][1];
1148 s
->pict_type
= AV_PICTURE_TYPE_I
+ get_bits1(&s
->gb
);
1150 s
->h263_long_vectors
= get_bits1(&s
->gb
);
1152 if (get_bits1(&s
->gb
) != 0) {
1153 av_log(s
->avctx
, AV_LOG_ERROR
, "H.263 SAC not supported\n");
1154 return -1; /* SAC: off */
1156 s
->obmc
= get_bits1(&s
->gb
); /* Advanced prediction mode */
1158 s
->pb_frame
= get_bits1(&s
->gb
);
1159 s
->chroma_qscale
= s
->qscale
= get_bits(&s
->gb
, 5);
1160 skip_bits1(&s
->gb
); /* Continuous Presence Multipoint mode: off */
1164 s
->avctx
->sample_aspect_ratio
= (AVRational
){12,11};
1165 s
->avctx
->framerate
= (AVRational
){ 30000, 1001 };
1171 ufep
= get_bits(&s
->gb
, 3); /* Update Full Extended PTYPE */
1173 /* ufep other than 0 and 1 are reserved */
1176 format
= get_bits(&s
->gb
, 3);
1177 ff_dlog(s
->avctx
, "ufep=1, format: %d\n", format
);
1178 s
->custom_pcf
= get_bits1(&s
->gb
);
1179 s
->umvplus
= get_bits1(&s
->gb
); /* Unrestricted Motion Vector */
1180 if (get_bits1(&s
->gb
) != 0) {
1181 av_log(s
->avctx
, AV_LOG_ERROR
, "Syntax-based Arithmetic Coding (SAC) not supported\n");
1183 s
->obmc
= get_bits1(&s
->gb
); /* Advanced prediction mode */
1184 s
->h263_aic
= get_bits1(&s
->gb
); /* Advanced Intra Coding (AIC) */
1185 s
->loop_filter
= get_bits1(&s
->gb
);
1186 if(s
->avctx
->lowres
)
1189 s
->h263_slice_structured
= get_bits1(&s
->gb
);
1190 if (get_bits1(&s
->gb
) != 0) {
1191 av_log(s
->avctx
, AV_LOG_ERROR
, "Reference Picture Selection not supported\n");
1193 if (get_bits1(&s
->gb
) != 0) {
1194 av_log(s
->avctx
, AV_LOG_ERROR
, "Independent Segment Decoding not supported\n");
1196 s
->alt_inter_vlc
= get_bits1(&s
->gb
);
1197 s
->modified_quant
= get_bits1(&s
->gb
);
1198 if(s
->modified_quant
)
1199 s
->chroma_qscale_table
= ff_h263_chroma_qscale_table
;
1201 skip_bits(&s
->gb
, 1); /* Prevent start code emulation */
1203 skip_bits(&s
->gb
, 3); /* Reserved */
1204 } else if (ufep
!= 0) {
1205 av_log(s
->avctx
, AV_LOG_ERROR
, "Bad UFEP type (%d)\n", ufep
);
1210 s
->pict_type
= get_bits(&s
->gb
, 3);
1211 switch(s
->pict_type
){
1212 case 0: s
->pict_type
= AV_PICTURE_TYPE_I
;break;
1213 case 1: s
->pict_type
= AV_PICTURE_TYPE_P
;break;
1214 case 2: s
->pict_type
= AV_PICTURE_TYPE_P
;s
->pb_frame
= 3;break;
1215 case 3: s
->pict_type
= AV_PICTURE_TYPE_B
;break;
1216 case 7: s
->pict_type
= AV_PICTURE_TYPE_I
;break; //ZYGO
1220 skip_bits(&s
->gb
, 2);
1221 s
->no_rounding
= get_bits1(&s
->gb
);
1222 skip_bits(&s
->gb
, 4);
1224 /* Get the picture dimensions */
1227 /* Custom Picture Format (CPFMT) */
1228 int aspect_ratio_info
= get_bits(&s
->gb
, 4);
1229 ff_dlog(s
->avctx
, "aspect: %d\n", aspect_ratio_info
);
1234 3 - 10:11 (525-type 4:3)
1235 4 - 16:11 (CIF 16:9)
1236 5 - 40:33 (525-type 16:9)
1239 width
= (get_bits(&s
->gb
, 9) + 1) * 4;
1240 check_marker(s
->avctx
, &s
->gb
, "in dimensions");
1241 height
= get_bits(&s
->gb
, 9) * 4;
1242 ff_dlog(s
->avctx
, "\nH.263+ Custom picture: %dx%d\n",width
,height
);
1243 if (aspect_ratio_info
== FF_ASPECT_EXTENDED
) {
1244 /* expected dimensions */
1245 s
->avctx
->sample_aspect_ratio
.num
= get_bits(&s
->gb
, 8);
1246 s
->avctx
->sample_aspect_ratio
.den
= get_bits(&s
->gb
, 8);
1248 s
->avctx
->sample_aspect_ratio
= ff_h263_pixel_aspect
[aspect_ratio_info
];
1251 width
= ff_h263_format
[format
][0];
1252 height
= ff_h263_format
[format
][1];
1253 s
->avctx
->sample_aspect_ratio
= (AVRational
){12,11};
1255 s
->avctx
->sample_aspect_ratio
.den
<<= s
->ehc_mode
;
1256 if ((width
== 0) || (height
== 0))
1263 s
->avctx
->framerate
.num
= 1800000;
1264 s
->avctx
->framerate
.den
= 1000 + get_bits1(&s
->gb
);
1265 s
->avctx
->framerate
.den
*= get_bits(&s
->gb
, 7);
1266 if(s
->avctx
->framerate
.den
== 0){
1267 av_log(s
, AV_LOG_ERROR
, "zero framerate\n");
1270 gcd
= av_gcd(s
->avctx
->framerate
.den
, s
->avctx
->framerate
.num
);
1271 s
->avctx
->framerate
.den
/= gcd
;
1272 s
->avctx
->framerate
.num
/= gcd
;
1274 s
->avctx
->framerate
= (AVRational
){ 30000, 1001 };
1279 skip_bits(&s
->gb
, 2); //extended Temporal reference
1284 if(get_bits1(&s
->gb
)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
1287 if(s
->h263_slice_structured
){
1288 if (get_bits1(&s
->gb
) != 0) {
1289 av_log(s
->avctx
, AV_LOG_ERROR
, "rectangular slices not supported\n");
1291 if (get_bits1(&s
->gb
) != 0) {
1292 av_log(s
->avctx
, AV_LOG_ERROR
, "unordered slices not supported\n");
1295 if (s
->pict_type
== AV_PICTURE_TYPE_B
) {
1296 skip_bits(&s
->gb
, 4); //ELNUM
1298 skip_bits(&s
->gb
, 4); // RLNUM
1303 s
->qscale
= get_bits(&s
->gb
, 5);
1306 if ((ret
= av_image_check_size(s
->width
, s
->height
, 0, s
)) < 0)
1309 if (!(s
->avctx
->flags2
& AV_CODEC_FLAG2_CHUNKS
)) {
1310 if ((s
->width
* s
->height
/ 256 / 8) > get_bits_left(&s
->gb
))
1311 return AVERROR_INVALIDDATA
;
1314 s
->mb_width
= (s
->width
+ 15) / 16;
1315 s
->mb_height
= (s
->height
+ 15) / 16;
1316 s
->mb_num
= s
->mb_width
* s
->mb_height
;
1319 skip_bits(&s
->gb
, 3); /* Temporal reference for B-pictures */
1321 skip_bits(&s
->gb
, 2); //extended Temporal reference
1322 skip_bits(&s
->gb
, 2); /* Quantization information for B-pictures */
1325 if (s
->pict_type
!=AV_PICTURE_TYPE_B
) {
1326 s
->time
= s
->picture_number
;
1327 s
->pp_time
= s
->time
- s
->last_non_b_time
;
1328 s
->last_non_b_time
= s
->time
;
1330 s
->time
= s
->picture_number
;
1331 s
->pb_time
= s
->pp_time
- (s
->last_non_b_time
- s
->time
);
1332 if (s
->pp_time
<=s
->pb_time
||
1333 s
->pp_time
<= s
->pp_time
- s
->pb_time
||
1338 ff_mpeg4_init_direct_mv(s
);
1342 if (skip_1stop_8data_bits(&s
->gb
) < 0)
1343 return AVERROR_INVALIDDATA
;
1345 if(s
->h263_slice_structured
){
1346 if (check_marker(s
->avctx
, &s
->gb
, "SEPB1") != 1) {
1350 ff_h263_decode_mba(s
);
1352 if (check_marker(s
->avctx
, &s
->gb
, "SEPB2") != 1) {
1358 if (s
->pict_type
== AV_PICTURE_TYPE_B
)
1362 s
->y_dc_scale_table
=
1363 s
->c_dc_scale_table
= ff_aic_dc_scale_table
;
1365 s
->y_dc_scale_table
=
1366 s
->c_dc_scale_table
= ff_mpeg1_dc_scale_table
;
1369 ff_h263_show_pict_info(s
);
1370 if (s
->pict_type
== AV_PICTURE_TYPE_I
&& s
->codec_tag
== AV_RL32("ZYGO") && get_bits_left(&s
->gb
) >= 85 + 13*3*16 + 50){
1372 for(i
=0; i
<85; i
++) av_log(s
->avctx
, AV_LOG_DEBUG
, "%d", get_bits1(&s
->gb
));
1373 av_log(s
->avctx
, AV_LOG_DEBUG
, "\n");
1374 for(i
=0; i
<13; i
++){
1376 int v
= get_bits(&s
->gb
, 8);
1377 v
|= get_sbits(&s
->gb
, 8) * (1 << 8);
1378 av_log(s
->avctx
, AV_LOG_DEBUG
, " %5d", v
);
1380 av_log(s
->avctx
, AV_LOG_DEBUG
, "\n");
1382 for(i
=0; i
<50; i
++) av_log(s
->avctx
, AV_LOG_DEBUG
, "%d", get_bits1(&s
->gb
));