Mercurial > libavcodec.hg
annotate h261dec.c @ 12074:fe1a6abe310a libavcodec
Disambiguate bitstream groups for AAC and RV30/RV40.
author | diego |
---|---|
date | Fri, 02 Jul 2010 12:55:36 +0000 |
parents | 7dd2a45249a9 |
children | c35d7bc64882 |
rev | line source |
---|---|
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
1 /* |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
2 * H261 decoder |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
4 * Copyright (c) 2004 Maarten Daniels |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
5 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
16 * Lesser General Public License for more details. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
17 * |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3740
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
21 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
22 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
23 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
24 * @file |
5057
5b63f62602fa
Split the h261.c file into separate files for the encoder, decoder and common stuff.
takis
parents:
4962
diff
changeset
|
25 * H.261 decoder. |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
26 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
27 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
28 #include "dsputil.h" |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
29 #include "avcodec.h" |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
30 #include "mpegvideo.h" |
11082 | 31 #include "h263.h" |
5158
65b1bfb3a74c
move definition of MB_TYPE_H261_FIL to h261.h so h261.c doesn't
mru
parents:
5129
diff
changeset
|
32 #include "h261.h" |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
33 #include "h261data.h" |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
34 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
35 #define H261_MBA_VLC_BITS 9 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
36 #define H261_MTYPE_VLC_BITS 6 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
37 #define H261_MV_VLC_BITS 7 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
38 #define H261_CBP_VLC_BITS 9 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
39 #define TCOEFF_VLC_BITS 9 |
2225 | 40 #define MBA_STUFFING 33 |
41 #define MBA_STARTCODE 34 | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
42 |
5057
5b63f62602fa
Split the h261.c file into separate files for the encoder, decoder and common stuff.
takis
parents:
4962
diff
changeset
|
43 extern uint8_t ff_h261_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3]; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
44 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
45 static VLC h261_mba_vlc; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
46 static VLC h261_mtype_vlc; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
47 static VLC h261_mv_vlc; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
48 static VLC h261_cbp_vlc; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
49 |
5057
5b63f62602fa
Split the h261.c file into separate files for the encoder, decoder and common stuff.
takis
parents:
4962
diff
changeset
|
50 static int h261_decode_block(H261Context * h, DCTELEM * block, int n, int coded); |
5b63f62602fa
Split the h261.c file into separate files for the encoder, decoder and common stuff.
takis
parents:
4962
diff
changeset
|
51 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6481
diff
changeset
|
52 static av_cold void h261_decode_init_vlc(H261Context *h){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
53 static int done = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
54 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
55 if(!done){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
56 done = 1; |
9400 | 57 INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35, |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
58 h261_mba_bits, 1, 1, |
9400 | 59 h261_mba_code, 1, 1, 662); |
60 INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10, | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
61 h261_mtype_bits, 1, 1, |
9400 | 62 h261_mtype_code, 1, 1, 80); |
63 INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17, | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
64 &h261_mv_tab[0][1], 2, 1, |
9400 | 65 &h261_mv_tab[0][0], 2, 1, 144); |
66 INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63, | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
67 &h261_cbp_tab[0][1], 2, 1, |
9400 | 68 &h261_cbp_tab[0][0], 2, 1, 512); |
5057
5b63f62602fa
Split the h261.c file into separate files for the encoder, decoder and common stuff.
takis
parents:
4962
diff
changeset
|
69 init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store); |
6940
778ecab25dd8
Change init_vlc_rl() so it does not use *alloc_static() anymore.
michael
parents:
6710
diff
changeset
|
70 INIT_VLC_RL(h261_rl_tcoeff, 552); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
71 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
72 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
73 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6481
diff
changeset
|
74 static av_cold int h261_decode_init(AVCodecContext *avctx){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
75 H261Context *h= avctx->priv_data; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
76 MpegEncContext * const s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
77 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
78 // set defaults |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
79 MPV_decode_defaults(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
80 s->avctx = avctx; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
81 |
2270 | 82 s->width = s->avctx->coded_width; |
83 s->height = s->avctx->coded_height; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
84 s->codec_id = s->avctx->codec->id; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
85 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
86 s->out_format = FMT_H261; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
87 s->low_delay= 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
88 avctx->pix_fmt= PIX_FMT_YUV420P; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
89 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
90 s->codec_id= avctx->codec->id; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
91 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
92 h261_decode_init_vlc(h); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
93 |
2225 | 94 h->gob_start_code_skipped = 0; |
2967 | 95 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
96 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
97 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
98 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
99 /** |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
100 * decodes the group of blocks header or slice header. |
6524 | 101 * @return <0 if an error occurred |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
102 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
103 static int h261_decode_gob_header(H261Context *h){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
104 unsigned int val; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
105 MpegEncContext * const s = &h->s; |
2967 | 106 |
2225 | 107 if ( !h->gob_start_code_skipped ){ |
108 /* Check for GOB Start Code */ | |
109 val = show_bits(&s->gb, 15); | |
110 if(val) | |
111 return -1; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
112 |
2225 | 113 /* We have a GBSC */ |
114 skip_bits(&s->gb, 16); | |
115 } | |
116 | |
117 h->gob_start_code_skipped = 0; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
118 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
119 h->gob_number = get_bits(&s->gb, 4); /* GN */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
120 s->qscale = get_bits(&s->gb, 5); /* GQUANT */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
121 |
2225 | 122 /* Check if gob_number is valid */ |
123 if (s->mb_height==18){ //cif | |
124 if ((h->gob_number<=0) || (h->gob_number>12)) | |
125 return -1; | |
126 } | |
127 else{ //qcif | |
128 if ((h->gob_number!=1) && (h->gob_number!=3) && (h->gob_number!=5)) | |
129 return -1; | |
130 } | |
131 | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
132 /* GEI */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
133 while (get_bits1(&s->gb) != 0) { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
134 skip_bits(&s->gb, 8); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
135 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
136 |
7461
5bcf597a321c
do not fail on qscale==0 if error resilience is high, fix broken quicktime h261, lotr.mov
bcoudurier
parents:
7040
diff
changeset
|
137 if(s->qscale==0) { |
5bcf597a321c
do not fail on qscale==0 if error resilience is high, fix broken quicktime h261, lotr.mov
bcoudurier
parents:
7040
diff
changeset
|
138 av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); |
7831 | 139 if (s->avctx->error_recognition >= FF_ER_COMPLIANT) |
7461
5bcf597a321c
do not fail on qscale==0 if error resilience is high, fix broken quicktime h261, lotr.mov
bcoudurier
parents:
7040
diff
changeset
|
140 return -1; |
5bcf597a321c
do not fail on qscale==0 if error resilience is high, fix broken quicktime h261, lotr.mov
bcoudurier
parents:
7040
diff
changeset
|
141 } |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
142 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
143 // For the first transmitted macroblock in a GOB, MBA is the absolute address. For |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
144 // subsequent macroblocks, MBA is the difference between the absolute addresses of |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
145 // the macroblock and the last transmitted macroblock. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
146 h->current_mba = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
147 h->mba_diff = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
148 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
149 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
150 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
151 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
152 /** |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
153 * decodes the group of blocks / video packet header. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
154 * @return <0 if no resync found |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
155 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
156 static int ff_h261_resync(H261Context *h){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
157 MpegEncContext * const s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
158 int left, ret; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
159 |
2225 | 160 if ( h->gob_start_code_skipped ){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
161 ret= h261_decode_gob_header(h); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
162 if(ret>=0) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
163 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
164 } |
2225 | 165 else{ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
166 if(show_bits(&s->gb, 15)==0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
167 ret= h261_decode_gob_header(h); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
168 if(ret>=0) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
169 return 0; |
2225 | 170 } |
5129 | 171 //OK, it is not where it is supposed to be ... |
2225 | 172 s->gb= s->last_resync_gb; |
173 align_get_bits(&s->gb); | |
10535
95f3daa991a2
Use get_bits_left() instead of size_in_bits - get_bits_count().
rbultje
parents:
9999
diff
changeset
|
174 left= get_bits_left(&s->gb); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
175 |
2225 | 176 for(;left>15+1+4+5; left-=8){ |
177 if(show_bits(&s->gb, 15)==0){ | |
178 GetBitContext bak= s->gb; | |
179 | |
180 ret= h261_decode_gob_header(h); | |
181 if(ret>=0) | |
182 return 0; | |
183 | |
184 s->gb= bak; | |
185 } | |
186 skip_bits(&s->gb, 8); | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
187 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
188 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
189 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
190 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
191 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
192 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
193 /** |
2134 | 194 * decodes skipped macroblocks |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
195 * @return 0 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
196 */ |
2134 | 197 static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2 ) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
198 { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
199 MpegEncContext * const s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
200 int i; |
2967 | 201 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
202 s->mb_intra = 0; |
2134 | 203 |
204 for(i=mba1; i<mba2; i++){ | |
205 int j, xy; | |
206 | |
207 s->mb_x= ((h->gob_number-1) % 2) * 11 + i % 11; | |
208 s->mb_y= ((h->gob_number-1) / 2) * 3 + i / 11; | |
209 xy = s->mb_x + s->mb_y * s->mb_stride; | |
210 ff_init_block_index(s); | |
211 ff_update_block_index(s); | |
212 | |
213 for(j=0;j<6;j++) | |
214 s->block_last_index[j] = -1; | |
215 | |
216 s->mv_dir = MV_DIR_FORWARD; | |
217 s->mv_type = MV_TYPE_16X16; | |
218 s->current_picture.mb_type[xy]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; | |
219 s->mv[0][0][0] = 0; | |
220 s->mv[0][0][1] = 0; | |
2628
511e3afc43e1
Ministry of English Composition, reporting for duty (and the word is "skipped", not "skiped"; "skiped" would rhyme with "hyped")
melanson
parents:
2453
diff
changeset
|
221 s->mb_skipped = 1; |
2291 | 222 h->mtype &= ~MB_TYPE_H261_FIL; |
2134 | 223 |
224 MPV_decode_mb(s, s->block); | |
225 } | |
226 | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
227 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
228 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
229 |
2046 | 230 static int decode_mv_component(GetBitContext *gb, int v){ |
231 int mv_diff = get_vlc2(gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2); | |
2225 | 232 |
233 /* check if mv_diff is valid */ | |
234 if ( mv_diff < 0 ) | |
235 return v; | |
236 | |
2046 | 237 mv_diff = mvmap[mv_diff]; |
238 | |
239 if(mv_diff && !get_bits1(gb)) | |
240 mv_diff= -mv_diff; | |
2967 | 241 |
2046 | 242 v += mv_diff; |
243 if (v <=-16) v+= 32; | |
244 else if(v >= 16) v-= 32; | |
245 | |
246 return v; | |
247 } | |
248 | |
2225 | 249 static int h261_decode_mb(H261Context *h){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
250 MpegEncContext * const s = &h->s; |
2330 | 251 int i, cbp, xy; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
252 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
253 cbp = 63; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
254 // Read mba |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
255 do{ |
2225 | 256 h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table, H261_MBA_VLC_BITS, 2); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
257 |
2225 | 258 /* Check for slice end */ |
259 /* NOTE: GOB can be empty (no MB data) or exist only of MBA_stuffing */ | |
260 if (h->mba_diff == MBA_STARTCODE){ // start code | |
261 h->gob_start_code_skipped = 1; | |
262 return SLICE_END; | |
263 } | |
264 } | |
265 while( h->mba_diff == MBA_STUFFING ); // stuffing | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
266 |
2225 | 267 if ( h->mba_diff < 0 ){ |
268 if ( get_bits_count(&s->gb) + 7 >= s->gb.size_in_bits ) | |
269 return SLICE_END; | |
270 | |
271 av_log(s->avctx, AV_LOG_ERROR, "illegal mba at %d %d\n", s->mb_x, s->mb_y); | |
272 return SLICE_ERROR; | |
273 } | |
274 | |
275 h->mba_diff += 1; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
276 h->current_mba += h->mba_diff; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
277 |
2225 | 278 if ( h->current_mba > MBA_STUFFING ) |
279 return SLICE_ERROR; | |
2967 | 280 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
281 s->mb_x= ((h->gob_number-1) % 2) * 11 + ((h->current_mba-1) % 11); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
282 s->mb_y= ((h->gob_number-1) / 2) * 3 + ((h->current_mba-1) / 11); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
283 xy = s->mb_x + s->mb_y * s->mb_stride; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
284 ff_init_block_index(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
285 ff_update_block_index(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
286 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
287 // Read mtype |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
288 h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
289 h->mtype = h261_mtype_map[h->mtype]; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
290 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
291 // Read mquant |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
292 if ( IS_QUANT ( h->mtype ) ){ |
2134 | 293 ff_set_qscale(s, get_bits(&s->gb, 5)); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
294 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
295 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
296 s->mb_intra = IS_INTRA4x4(h->mtype); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
297 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
298 // Read mv |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
299 if ( IS_16X16 ( h->mtype ) ){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
300 // Motion vector data is included for all MC macroblocks. MVD is obtained from the macroblock vector by subtracting the |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
301 // vector of the preceding macroblock. For this calculation the vector of the preceding macroblock is regarded as zero in the |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
302 // following three situations: |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
303 // 1) evaluating MVD for macroblocks 1, 12 and 23; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
304 // 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
305 // 3) MTYPE of the previous macroblock was not MC. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
306 if ( ( h->current_mba == 1 ) || ( h->current_mba == 12 ) || ( h->current_mba == 23 ) || |
2330 | 307 ( h->mba_diff != 1)) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
308 { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
309 h->current_mv_x = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
310 h->current_mv_y = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
311 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
312 |
2046 | 313 h->current_mv_x= decode_mv_component(&s->gb, h->current_mv_x); |
314 h->current_mv_y= decode_mv_component(&s->gb, h->current_mv_y); | |
2330 | 315 }else{ |
316 h->current_mv_x = 0; | |
317 h->current_mv_y = 0; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
318 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
319 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
320 // Read cbp |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
321 if ( HAS_CBP( h->mtype ) ){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
322 cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
323 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
324 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
325 if(s->mb_intra){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
326 s->current_picture.mb_type[xy]= MB_TYPE_INTRA; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
327 goto intra; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
328 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
329 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
330 //set motion vectors |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
331 s->mv_dir = MV_DIR_FORWARD; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
332 s->mv_type = MV_TYPE_16X16; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
333 s->current_picture.mb_type[xy]= MB_TYPE_16x16 | MB_TYPE_L0; |
2330 | 334 s->mv[0][0][0] = h->current_mv_x * 2;//gets divided by 2 in motion compensation |
335 s->mv[0][0][1] = h->current_mv_y * 2; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
336 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
337 intra: |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
338 /* decode each block */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
339 if(s->mb_intra || HAS_CBP(h->mtype)){ |
2632 | 340 s->dsp.clear_blocks(s->block[0]); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
341 for (i = 0; i < 6; i++) { |
2225 | 342 if (h261_decode_block(h, s->block[i], i, cbp&32) < 0){ |
343 return SLICE_ERROR; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
344 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
345 cbp+=cbp; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
346 } |
2632 | 347 }else{ |
348 for (i = 0; i < 6; i++) | |
349 s->block_last_index[i]= -1; | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
350 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
351 |
2225 | 352 MPV_decode_mb(s, s->block); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
353 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
354 return SLICE_OK; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
355 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
356 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
357 /** |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
358 * decodes a macroblock |
6524 | 359 * @return <0 if an error occurred |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
360 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
361 static int h261_decode_block(H261Context * h, DCTELEM * block, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
362 int n, int coded) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
363 { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
364 MpegEncContext * const s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
365 int code, level, i, j, run; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
366 RLTable *rl = &h261_rl_tcoeff; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
367 const uint8_t *scan_table; |
2967 | 368 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
369 // For the variable length encoding there are two code tables, one being used for |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
370 // the first transmitted LEVEL in INTER, INTER+MC and INTER+MC+FIL blocks, the second |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
371 // for all other LEVELs except the first one in INTRA blocks which is fixed length |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
372 // coded with 8 bits. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
373 // NOTE: the two code tables only differ in one VLC so we handle that manually. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
374 scan_table = s->intra_scantable.permutated; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
375 if (s->mb_intra){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
376 /* DC coef */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
377 level = get_bits(&s->gb, 8); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
378 // 0 (00000000b) and -128 (10000000b) are FORBIDDEN |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
379 if((level&0x7F) == 0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
380 av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
381 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
382 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
383 // The code 1000 0000 is not used, the reconstruction level of 1024 being coded as 1111 1111. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
384 if (level == 255) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
385 level = 128; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
386 block[0] = level; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
387 i = 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
388 }else if(coded){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
389 // Run Level Code |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
390 // EOB Not possible for first level when cbp is available (that's why the table is different) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
391 // 0 1 1s |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
392 // * * 0* |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
393 int check = show_bits(&s->gb, 2); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
394 i = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
395 if ( check & 0x2 ){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
396 skip_bits(&s->gb, 2); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
397 block[0] = ( check & 0x1 ) ? -1 : 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
398 i = 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
399 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
400 }else{ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
401 i = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
402 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
403 if(!coded){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
404 s->block_last_index[n] = i - 1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
405 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
406 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
407 for(;;){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
408 code = get_vlc2(&s->gb, rl->vlc.table, TCOEFF_VLC_BITS, 2); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
409 if (code < 0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
410 av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
411 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
412 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
413 if (code == rl->n) { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
414 /* escape */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
415 // The remaining combinations of (run, level) are encoded with a 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits level. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
416 run = get_bits(&s->gb, 6); |
2332 | 417 level = get_sbits(&s->gb, 8); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
418 }else if(code == 0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
419 break; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
420 }else{ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
421 run = rl->table_run[code]; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
422 level = rl->table_level[code]; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
423 if (get_bits1(&s->gb)) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
424 level = -level; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
425 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
426 i += run; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
427 if (i >= 64){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
428 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n", s->mb_x, s->mb_y); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
429 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
430 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
431 j = scan_table[i]; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
432 block[j] = level; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
433 i++; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
434 } |
2134 | 435 s->block_last_index[n] = i-1; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
436 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
437 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
438 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
439 /** |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
440 * decodes the H261 picture header. |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
441 * @return <0 if no startcode found |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
442 */ |
3071
cc0357a90e8f
make some functions static (patch by Dieter < freebsd at sopwith.solgatos.com >)
aurel
parents:
3036
diff
changeset
|
443 static int h261_decode_picture_header(H261Context *h){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
444 MpegEncContext * const s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
445 int format, i; |
2290 | 446 uint32_t startcode= 0; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
447 |
10535
95f3daa991a2
Use get_bits_left() instead of size_in_bits - get_bits_count().
rbultje
parents:
9999
diff
changeset
|
448 for(i= get_bits_left(&s->gb); i>24; i-=1){ |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
449 startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
450 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
451 if(startcode == 0x10) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
452 break; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
453 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
454 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
455 if (startcode != 0x10){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
456 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
457 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
458 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
459 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
460 /* temporal reference */ |
3580 | 461 i= get_bits(&s->gb, 5); /* picture timestamp */ |
462 if(i < (s->picture_number&31)) | |
463 i += 32; | |
464 s->picture_number = (s->picture_number&~31) + i; | |
465 | |
466 s->avctx->time_base= (AVRational){1001, 30000}; | |
467 s->current_picture.pts= s->picture_number; | |
468 | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
469 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
470 /* PTYPE starts here */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
471 skip_bits1(&s->gb); /* split screen off */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
472 skip_bits1(&s->gb); /* camera off */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
473 skip_bits1(&s->gb); /* freeze picture release off */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
474 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
475 format = get_bits1(&s->gb); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
476 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
477 //only 2 formats possible |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
478 if (format == 0){//QCIF |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
479 s->width = 176; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
480 s->height = 144; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
481 s->mb_width = 11; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
482 s->mb_height = 9; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
483 }else{//CIF |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
484 s->width = 352; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
485 s->height = 288; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
486 s->mb_width = 22; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
487 s->mb_height = 18; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
488 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
489 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
490 s->mb_num = s->mb_width * s->mb_height; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
491 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
492 skip_bits1(&s->gb); /* still image mode off */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
493 skip_bits1(&s->gb); /* Reserved */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
494 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
495 /* PEI */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
496 while (get_bits1(&s->gb) != 0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
497 skip_bits(&s->gb, 8); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
498 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
499 |
6481 | 500 // h261 has no I-FRAMES, but if we pass FF_I_TYPE for the first frame, the codec crashes if it does |
2225 | 501 // not contain all I-blocks (e.g. when a packet is lost) |
6481 | 502 s->pict_type = FF_P_TYPE; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
503 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
504 h->gob_number = 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
505 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
506 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
507 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
508 static int h261_decode_gob(H261Context *h){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
509 MpegEncContext * const s = &h->s; |
2967 | 510 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
511 ff_set_qscale(s, s->qscale); |
2134 | 512 |
513 /* decode mb's */ | |
2225 | 514 while(h->current_mba <= MBA_STUFFING) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
515 { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
516 int ret; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
517 /* DCT & quantize */ |
2225 | 518 ret= h261_decode_mb(h); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
519 if(ret<0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
520 if(ret==SLICE_END){ |
2967 | 521 h261_decode_mb_skipped(h, h->current_mba, 33); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
522 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
523 } |
2225 | 524 av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", s->mb_x + s->mb_y*s->mb_stride); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
525 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
526 } |
2967 | 527 |
2134 | 528 h261_decode_mb_skipped(h, h->current_mba-h->mba_diff, h->current_mba-1); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
529 } |
2967 | 530 |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
531 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
532 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
533 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
534 /** |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
535 * returns the number of bytes consumed for building the current frame |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
536 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
537 static int get_consumed_bytes(MpegEncContext *s, int buf_size){ |
2356 | 538 int pos= get_bits_count(&s->gb)>>3; |
5127 | 539 if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but ...) |
2356 | 540 if(pos+10>buf_size) pos=buf_size; // oops ;) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
541 |
2356 | 542 return pos; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
543 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
544 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
545 static int h261_decode_frame(AVCodecContext *avctx, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
546 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
547 AVPacket *avpkt) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
548 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
549 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
550 int buf_size = avpkt->size; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
551 H261Context *h= avctx->priv_data; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
552 MpegEncContext *s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
553 int ret; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
554 AVFrame *pict = data; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
555 |
9999
c78fd9154378
Change av_log() calls surrounded by '#ifdef DEBUG' into dprintf macros.
diego
parents:
9400
diff
changeset
|
556 dprintf(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size); |
c78fd9154378
Change av_log() calls surrounded by '#ifdef DEBUG' into dprintf macros.
diego
parents:
9400
diff
changeset
|
557 dprintf(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
558 s->flags= avctx->flags; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
559 s->flags2= avctx->flags2; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
560 |
2356 | 561 h->gob_start_code_skipped=0; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
562 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
563 retry: |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
564 |
2047 | 565 init_get_bits(&s->gb, buf, buf_size*8); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
566 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
567 if(!s->context_initialized){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
568 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
569 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
570 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
571 |
5127 | 572 //we need to set current_picture_ptr before reading the header, otherwise we cannot store anyting im there |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
573 if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
574 int i= ff_find_unused_picture(s, 0); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
575 s->current_picture_ptr= &s->picture[i]; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
576 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
577 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
578 ret = h261_decode_picture_header(h); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
579 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
580 /* skip if the header was thrashed */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
581 if (ret < 0){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
582 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
583 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
584 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
585 |
2270 | 586 if (s->width != avctx->coded_width || s->height != avctx->coded_height){ |
5127 | 587 ParseContext pc= s->parse_context; //FIXME move this demuxing hack to libavformat |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
588 s->parse_context.buffer=0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
589 MPV_common_end(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
590 s->parse_context= pc; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
591 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
592 if (!s->context_initialized) { |
2270 | 593 avcodec_set_dimensions(avctx, s->width, s->height); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
594 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
595 goto retry; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
596 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
597 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
598 // for hurry_up==5 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
599 s->current_picture.pict_type= s->pict_type; |
6481 | 600 s->current_picture.key_frame= s->pict_type == FF_I_TYPE; |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
601 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
602 /* skip everything if we are in a hurry>=5 */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
603 if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); |
6481 | 604 if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE) |
605 ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) | |
2792 | 606 || avctx->skip_frame >= AVDISCARD_ALL) |
607 return get_consumed_bytes(s, buf_size); | |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
608 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
609 if(MPV_frame_start(s, avctx) < 0) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
610 return -1; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
611 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
612 ff_er_frame_start(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
613 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
614 /* decode each macroblock */ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
615 s->mb_x=0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
616 s->mb_y=0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
617 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
618 while(h->gob_number < (s->mb_height==18 ? 12 : 5)){ |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
619 if(ff_h261_resync(h)<0) |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
620 break; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
621 h261_decode_gob(h); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
622 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
623 MPV_frame_end(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
624 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
625 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
626 assert(s->current_picture.pict_type == s->pict_type); |
2356 | 627 *pict= *(AVFrame*)s->current_picture_ptr; |
2047 | 628 ff_print_debug_info(s, pict); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
629 |
2047 | 630 *data_size = sizeof(AVFrame); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
631 |
2047 | 632 return get_consumed_bytes(s, buf_size); |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
633 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
634 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6481
diff
changeset
|
635 static av_cold int h261_decode_end(AVCodecContext *avctx) |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
636 { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
637 H261Context *h= avctx->priv_data; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
638 MpegEncContext *s = &h->s; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
639 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
640 MPV_common_end(s); |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
641 return 0; |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
642 } |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
643 |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
644 AVCodec h261_decoder = { |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
645 "h261", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11082
diff
changeset
|
646 AVMEDIA_TYPE_VIDEO, |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
647 CODEC_ID_H261, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
648 sizeof(H261Context), |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
649 h261_decode_init, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
650 NULL, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
651 h261_decode_end, |
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
652 h261_decode_frame, |
2356 | 653 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6940
diff
changeset
|
654 .long_name = NULL_IF_CONFIG_SMALL("H.261"), |
2044
b6f2add2511e
h261 decoder by (Maarten Daniels <maarten.daniels at student dot luc dot ac dot be>)
michael
parents:
diff
changeset
|
655 }; |