Mercurial > libavcodec.hg
annotate vc9.c @ 2487:b09bc77eb2fb libavcodec
Stereo MACE fix by Burkhard Plaum <plaum AT ipf DOT uni-stuttgart DOT de>
Still doesn't work with our mov demuxer though...
author | mmu_man |
---|---|
date | Tue, 01 Feb 2005 15:13:27 +0000 |
parents | 4eb9d61cad4e |
children | 69adfbbdcdeb |
rev | line source |
---|---|
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1 /* |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2 * VC-9 and WMV3 decoder |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
3 * Copyright (c) 2005 Anonymous |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
4 * Copyright (c) 2005 Alex Beregszaszi |
2462 | 5 * Copyright (c) 2005 Michael Niedermayer |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
6 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
7 * This library is free software; you can redistribute it and/or |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
10 * version 2 of the License, or (at your option) any later version. |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
11 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
12 * This library is distributed in the hope that it will be useful, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
16 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
18 * License along with this library; if not, write to the Free Software |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
20 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
21 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
22 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
23 /** |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
24 * @file vc9.c |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
25 * VC-9 and WMV3 decoder |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
26 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
27 * TODO: Norm-6 bitplane imode, most AP stuff, optimize, all of MB layer :) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
28 * TODO: use MPV_ !! |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
29 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
30 #include "common.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
31 #include "dsputil.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
32 #include "avcodec.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
33 #include "mpegvideo.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
34 #include "vc9data.h" |
2474 | 35 |
2476
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
36 #undef NDEBUG |
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
37 #include <assert.h> |
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
38 |
2465
5565203c95ee
use dc tables from msmpeg4 instead of duplicating them patch by anonymous
michael
parents:
2464
diff
changeset
|
39 extern const uint32_t ff_table0_dc_lum[120][2], ff_table1_dc_lum[120][2]; |
5565203c95ee
use dc tables from msmpeg4 instead of duplicating them patch by anonymous
michael
parents:
2464
diff
changeset
|
40 extern const uint32_t ff_table0_dc_chroma[120][2], ff_table1_dc_chroma[120][2]; |
2474 | 41 extern VLC ff_msmp4_dc_luma_vlc[2], ff_msmp4_dc_chroma_vlc[2]; |
42 #define MB_INTRA_VLC_BITS 9 | |
43 extern VLC ff_msmp4_mb_i_vlc; | |
44 #define DC_VLC_BITS 9 | |
45 static const uint16_t table_mb_intra[64][2]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
46 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
47 /* Some inhibiting stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
48 #define HAS_ADVANCED_PROFILE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
49 #define TRACE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
50 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
51 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
52 # define INIT_VLC(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
53 codes, codes_wrap, codes_size, use_static) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
54 if (init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
55 codes, codes_wrap, codes_size, use_static) < 0) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
56 { \ |
2474 | 57 av_log(v->s.avctx, AV_LOG_ERROR, "Error for " # vlc " (%i)\n", i); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
58 return -1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
59 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
60 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
61 # define INIT_VLC(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
62 codes, codes_wrap, codes_size, use_static) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
63 init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
64 codes, codes_wrap, codes_size, use_static) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
65 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
66 |
2482 | 67 /** Available Profiles */ |
68 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
69 #define PROFILE_SIMPLE 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
70 #define PROFILE_MAIN 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
71 #define PROFILE_ADVANCED 3 |
2482 | 72 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
73 |
2482 | 74 /** Sequence quantizer mode */ |
75 //@{ | |
2483 | 76 #define QUANT_FRAME_IMPLICIT 0 ///< Implicitly specified at frame level |
77 #define QUANT_FRAME_EXPLICIT 1 ///< Explicitly specified at frame level | |
78 #define QUANT_NON_UNIFORM 2 ///< Non-uniform quant used for all frames | |
79 #define QUANT_UNIFORM 3 ///< Uniform quant used for all frames | |
2482 | 80 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
81 |
2482 | 82 /** Where quant can be changed */ |
83 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
84 #define DQPROFILE_FOUR_EDGES 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
85 #define DQPROFILE_DOUBLE_EDGES 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
86 #define DQPROFILE_SINGLE_EDGE 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
87 #define DQPROFILE_ALL_MBS 3 |
2482 | 88 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
89 |
2482 | 90 /** @name Where quant can be changed |
91 */ | |
92 //@{ | |
93 #define DQPROFILE_FOUR_EDGES 0 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
94 #define DQSINGLE_BEDGE_LEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
95 #define DQSINGLE_BEDGE_TOP 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
96 #define DQSINGLE_BEDGE_RIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
97 #define DQSINGLE_BEDGE_BOTTOM 3 |
2482 | 98 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
99 |
2482 | 100 /** Which pair of edges is quantized with ALTPQUANT */ |
101 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
102 #define DQDOUBLE_BEDGE_TOPLEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
103 #define DQDOUBLE_BEDGE_TOPRIGHT 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
104 #define DQDOUBLE_BEDGE_BOTTOMRIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
105 #define DQDOUBLE_BEDGE_BOTTOMLEFT 3 |
2482 | 106 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
107 |
2482 | 108 /** MV modes for P frames */ |
109 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
110 #define MV_PMODE_1MV_HPEL_BILIN 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
111 #define MV_PMODE_1MV 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
112 #define MV_PMODE_1MV_HPEL 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
113 #define MV_PMODE_MIXED_MV 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
114 #define MV_PMODE_INTENSITY_COMP 4 |
2482 | 115 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
116 |
2482 | 117 /** @name MV types for B frames */ |
118 //@{ | |
119 #define BMV_TYPE_BACKWARD 0 | |
2462 | 120 #define BMV_TYPE_BACKWARD 0 |
121 #define BMV_TYPE_FORWARD 1 | |
122 #define BMV_TYPE_INTERPOLATED 3 | |
2482 | 123 //@} |
2462 | 124 |
2482 | 125 /** MV P mode - the 5th element is only used for mode 1 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
126 static const uint8_t mv_pmode_table[2][5] = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
127 { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV, MV_PMODE_INTENSITY_COMP }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
128 { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_INTENSITY_COMP } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
129 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
130 |
2482 | 131 /** One more frame type */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
132 #define BI_TYPE 7 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
133 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
134 static const int fps_nr[5] = { 24, 25, 30, 50, 60 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
135 fps_dr[2] = { 1000, 1001 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
136 static const uint8_t pquant_table[3][32] = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
137 { /* Implicit quantizer */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
138 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
139 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
140 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
141 { /* Explicit quantizer, pquantizer uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
142 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
143 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
144 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
145 { /* Explicit quantizer, pquantizer non-uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
146 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
147 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
148 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
149 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
150 |
2482 | 151 /** @name VC-9 VLC tables and defines |
152 * @todo TODO move this into the context | |
153 */ | |
154 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
155 #define VC9_BFRACTION_VLC_BITS 7 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
156 static VLC vc9_bfraction_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
157 #define VC9_IMODE_VLC_BITS 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
158 static VLC vc9_imode_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
159 #define VC9_NORM2_VLC_BITS 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
160 static VLC vc9_norm2_vlc; |
2482 | 161 #if VLC_NORM6_METH0D == 1 |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
162 #define VC9_NORM6_VLC_BITS 9 |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
163 static VLC vc9_norm6_vlc; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
164 #endif |
2482 | 165 #if VLC_NORM6_METH0D == 2 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
166 #define VC9_NORM6_FIRST_BITS 8 |
2476
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
167 #define VC9_NORM6_SECOND_BITS 8 |
2482 | 168 static VLC vc9_norm6_first_vlc, vc9_norm6_second_vlc; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
169 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
170 /* Could be optimized, one table only needs 8 bits */ |
2462 | 171 #define VC9_TTMB_VLC_BITS 9 //12 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
172 static VLC vc9_ttmb_vlc[3]; |
2462 | 173 #define VC9_MV_DIFF_VLC_BITS 9 //15 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
174 static VLC vc9_mv_diff_vlc[4]; |
2462 | 175 #define VC9_CBPCY_P_VLC_BITS 9 //14 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
176 static VLC vc9_cbpcy_p_vlc[4]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
177 #define VC9_4MV_BLOCK_PATTERN_VLC_BITS 6 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
178 static VLC vc9_4mv_block_pattern_vlc[4]; |
2482 | 179 //@} |
2462 | 180 |
2482 | 181 /** Bitplane struct |
182 * We mainly need data and is_raw, so this struct could be avoided | |
183 * to save a level of indirection; feel free to modify | |
184 * @fixme For now, stride=width | |
185 * @warning Data are bits, either 1 or 0 | |
186 */ | |
2462 | 187 typedef struct BitPlane { |
2482 | 188 uint8_t *data; ///< Data buffer |
189 int width; ///< Width of the buffer | |
190 int stride; ///< Stride of the buffer | |
191 int height; ///< Plane height | |
192 uint8_t is_raw; ///< Bit values must be read at MB level | |
2462 | 193 } BitPlane; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
194 |
2482 | 195 /** The VC9 Context */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
196 typedef struct VC9Context{ |
2482 | 197 MpegEncContext s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
198 |
2482 | 199 /** Simple/Main Profile sequence header */ |
200 //@{ | |
201 int res_sm; ///< reserved, 2b | |
202 int res_x8; ///< reserved | |
203 int multires; ///< frame-level RESPIC syntax element present | |
204 int res_fasttx; ///< reserved, always 1 | |
205 int res_transtab; ///< reserved, always 0 | |
206 int rangered; ///< RANGEREDFRM (range reduction) syntax element present | |
207 ///< at frame level | |
208 int res_rtm_flag; ///< reserved, set to 1 | |
209 int reserved; ///< reserved | |
210 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
211 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
212 #if HAS_ADVANCED_PROFILE |
2482 | 213 /** Advanced Profile */ |
214 //@{ | |
215 int level; ///< 3bits, for Advanced/Simple Profile, provided by TS layer | |
216 int chromaformat; ///< 2bits, 2=4:2:0, only defined | |
217 int postprocflag; ///< Per-frame processing suggestion flag present | |
218 int broadcast; ///< TFF/RFF present | |
219 int interlace; ///< Progressive/interlaced (RPTFTM syntax element) | |
220 int tfcntrflag; ///< TFCNTR present | |
221 int panscanflag; ///< NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present | |
222 int extended_dmv; ///< Additional extended dmv range at P/B frame-level | |
223 int color_prim; ///< 8bits, chroma coordinates of the color primaries | |
224 int transfer_char; ///< 8bits, Opto-electronic transfer characteristics | |
225 int matrix_coef; ///< 8bits, Color primaries->YCbCr transform matrix | |
226 int hrd_param_flag; ///< Presence of Hypothetical Reference | |
227 ///< Decoder parameters | |
228 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
229 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
230 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
231 |
2482 | 232 /** Sequence header data for all Profiles |
233 * TODO: choose between ints, uint8_ts and monobit flags | |
234 */ | |
235 //@{ | |
236 int profile; ///< 2bits, Profile | |
237 int frmrtq_postproc; ///< 3bits, | |
238 int bitrtq_postproc; ///< 5bits, quantized framerate-based postprocessing strength | |
239 int fastuvmc; ///< Rounding of qpel vector to hpel ? (not in Simple) | |
240 int extended_mv; ///< Ext MV in P/B (not in Simple) | |
241 int dquant; ///< How qscale varies with MBs, 2bits (not in Simple) | |
242 int vstransform; ///< variable-size [48]x[48] transform type + info | |
243 int overlap; ///< overlapped transforms in use | |
244 int quantizer_mode; ///< 2bits, quantizer mode used for sequence, see QUANT_* | |
245 int finterpflag; ///< INTERPFRM present | |
246 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
247 |
2482 | 248 /** Frame decoding info for all profiles */ |
249 //@{ | |
250 uint8_t mv_mode; ///< MV coding monde | |
251 uint8_t mv_mode2; ///< Secondary MV coding mode (B frames) | |
252 uint8_t pq, altpq; ///< Current/alternate frame quantizer scale | |
253 /** pquant parameters */ | |
254 //@{ | |
255 uint8_t dquantfrm; | |
256 uint8_t dqprofile; | |
257 uint8_t dqsbedge; | |
258 uint8_t dqbilevel; | |
259 //@} | |
260 int ac_table_level; ///< Index for AC tables from ACFRM element | |
261 VLC *luma_dc_vlc; ///< Pointer to current luma DC VLC table | |
262 VLC *chroma_dc_vlc; ///< Pointer to current luma AC VLC table | |
263 int ttfrm; ///< Transform type info present at frame level | |
264 uint8_t ttmbf; ///< Transform type | |
265 /** Luma compensation parameters */ | |
266 //@{ | |
267 uint8_t lumscale; | |
268 uint8_t lumshift; | |
269 //@} | |
270 int16_t bfraction; ///< Relative position % anchors=> how to scale MVs | |
271 uint8_t halfpq; ///< Uniform quant over image and qp+.5 | |
272 uint8_t respic; ///< Frame-level flag for resized images | |
273 int buffer_fullness; ///< HRD info | |
274 /** Ranges: | |
275 * -# 0 -> [-64n 63.f] x [-32, 31.f] | |
276 * -# 1 -> [-128, 127.f] x [-64, 63.f] | |
277 * -# 2 -> [-512, 511.f] x [-128, 127.f] | |
278 * -# 3 -> [-1024, 1023.f] x [-256, 255.f] | |
279 */ | |
280 uint8_t mvrange; | |
2483 | 281 uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use |
2482 | 282 uint8_t *previous_line_cbpcy; ///< To use for predicted CBPCY |
283 VLC *cbpcy_vlc; ///< Current CBPCY VLC table | |
284 VLC *ttmb_vlc; ///< Current MB Transform Type VLC table | |
285 BitPlane mv_type_mb_plane; ///< bitplane for mv_type == (4MV) | |
286 BitPlane skip_mb_plane; ///< bitplane for skipped MBs | |
287 BitPlane direct_mb_plane; ///< bitplane for "direct" MBs | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
288 |
2482 | 289 /** Frame decoding info for S/M profiles only */ |
290 //@{ | |
291 uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128) | |
292 uint8_t interpfrm; | |
293 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
294 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
295 #if HAS_ADVANCED_PROFILE |
2482 | 296 /** Frame decoding info for Advanced profile */ |
297 //@{ | |
298 uint8_t fcm; ///< 0->Progressive, 2->Frame-Interlace, 3->Field-Interlace | |
299 uint8_t numpanscanwin; | |
300 uint8_t tfcntr; | |
301 uint8_t rptfrm, tff, rff; | |
2483 | 302 uint16_t topleftx; |
303 uint16_t toplefty; | |
304 uint16_t bottomrightx; | |
305 uint16_t bottomrighty; | |
2482 | 306 uint8_t uvsamp; |
307 uint8_t postproc; | |
308 int hrd_num_leaky_buckets; | |
309 uint8_t bit_rate_exponent; | |
310 uint8_t buffer_size_exponent; | |
311 BitPlane ac_pred_plane; ///< AC prediction flags bitplane | |
312 BitPlane over_flags_plane; ///< Overflags bitplane | |
313 uint8_t condover; | |
314 uint16_t *hrd_rate, *hrd_buffer; | |
315 int ac2_table_level; ///< Index for AC2 tables from AC2FRM element | |
316 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
317 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
318 } VC9Context; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
319 |
2482 | 320 /** |
321 * Get unary code of limited length | |
322 * @fixme FIXME Slow and ugly | |
323 * @param gb GetBitContext | |
324 * @param[in] stop The bitstop value (unary code of 1's or 0's) | |
325 * @param[in] len Maximum length | |
326 * @return Unary length/index | |
327 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
328 static int get_prefix(GetBitContext *gb, int stop, int len) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
329 { |
2462 | 330 #if 1 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
331 int i = 0, tmp = !stop; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
332 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
333 while (i != len && tmp != stop) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
334 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
335 tmp = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
336 i++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
337 } |
2483 | 338 if (i == len && tmp != stop) return len+1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
339 return i; |
2462 | 340 #else |
341 unsigned int buf; | |
342 int log; | |
343 | |
344 OPEN_READER(re, gb); | |
345 UPDATE_CACHE(re, gb); | |
346 buf=GET_CACHE(re, gb); //Still not sure | |
347 if (stop) buf = ~buf; | |
348 | |
349 log= av_log2(-buf); //FIXME: -? | |
350 if (log < limit){ | |
351 LAST_SKIP_BITS(re, gb, log+1); | |
352 CLOSE_READER(re, gb); | |
353 return log; | |
354 } | |
355 | |
356 LAST_SKIP_BITS(re, gb, limit); | |
357 CLOSE_READER(re, gb); | |
358 return limit; | |
359 #endif | |
360 } | |
361 | |
2482 | 362 /** |
363 * Init VC-9 specific tables and VC9Context members | |
364 * @param v The VC9Context to initialize | |
365 * @return Status | |
366 */ | |
2474 | 367 static int vc9_init_common(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
368 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
369 static int done = 0; |
2483 | 370 int i = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
371 |
2462 | 372 /* Set the bit planes */ |
373 v->mv_type_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
374 v->direct_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
375 v->skip_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
376 #if HAS_ADVANCED_PROFILE |
2462 | 377 v->ac_pred_plane = v->over_flags_plane = (struct BitPlane) { NULL, 0, 0, 0 }; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
378 v->hrd_rate = v->hrd_buffer = NULL; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
379 #endif |
2462 | 380 |
381 /* VLC tables */ | |
2482 | 382 #if VLC_NORM6_METH0D == 1 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
383 # if 0 // spec -> actual tables converter |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
384 for(i=0; i<64; i++){ |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
385 int code= (vc9_norm6_spec[i][1] << vc9_norm6_spec[i][4]) + vc9_norm6_spec[i][3]; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
386 av_log(NULL, AV_LOG_DEBUG, "0x%03X, ", code); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
387 if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
388 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
389 for(i=0; i<64; i++){ |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
390 int code= vc9_norm6_spec[i][2] + vc9_norm6_spec[i][4]; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
391 av_log(NULL, AV_LOG_DEBUG, "%2d, ", code); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
392 if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
393 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
394 # endif |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
395 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
396 if(!done) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
397 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
398 done = 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
399 INIT_VLC(&vc9_bfraction_vlc, VC9_BFRACTION_VLC_BITS, 23, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
400 vc9_bfraction_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
401 vc9_bfraction_codes, 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
402 INIT_VLC(&vc9_norm2_vlc, VC9_NORM2_VLC_BITS, 4, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
403 vc9_norm2_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
404 vc9_norm2_codes, 1, 1, 1); |
2482 | 405 #if VLC_NORM6_METH0D == 1 |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
406 INIT_VLC(&vc9_norm6_vlc, VC9_NORM6_VLC_BITS, 64, |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
407 vc9_norm6_bits, 1, 1, |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
408 vc9_norm6_codes, 2, 2, 1); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
409 #endif |
2482 | 410 #if VLC_NORM6_METH0D == 2 |
411 INIT_VLC(&vc9_norm6_first_vlc, VC9_NORM6_FIRST_BITS, 24, | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
412 &vc9_norm6_first[0][1], 1, 1, |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
413 &vc9_norm6_first[0][0], 1, 1, 1); |
2482 | 414 INIT_VLC(&vc9_norm6_second_vlc, VC9_NORM6_SECOND_BITS, 22, |
415 &vc9_norm6_second[0][1], 1, 1, | |
416 &vc9_norm6_second[0][0], 1, 1, 1); | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
417 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
418 INIT_VLC(&vc9_imode_vlc, VC9_IMODE_VLC_BITS, 7, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
419 vc9_imode_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
420 vc9_imode_codes, 1, 1, 1); |
2462 | 421 for (i=0; i<3; i++) |
422 { | |
423 INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16, | |
424 vc9_ttmb_bits[i], 1, 1, | |
425 vc9_ttmb_codes[i], 2, 2, 1); | |
426 } | |
427 for(i=0; i<4; i++) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
428 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
429 INIT_VLC(&vc9_4mv_block_pattern_vlc[i], VC9_4MV_BLOCK_PATTERN_VLC_BITS, 16, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
430 vc9_4mv_block_pattern_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
431 vc9_4mv_block_pattern_codes[i], 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
432 INIT_VLC(&vc9_cbpcy_p_vlc[i], VC9_CBPCY_P_VLC_BITS, 64, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
433 vc9_cbpcy_p_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
434 vc9_cbpcy_p_codes[i], 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
435 INIT_VLC(&vc9_mv_diff_vlc[i], VC9_MV_DIFF_VLC_BITS, 73, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
436 vc9_mv_diff_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
437 vc9_mv_diff_codes[i], 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
438 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
439 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
440 |
2462 | 441 /* Other defaults */ |
442 v->pq = -1; | |
443 v->mvrange = 0; /* 7.1.1.18, p80 */ | |
444 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
445 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
446 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
447 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
448 #if HAS_ADVANCED_PROFILE |
2482 | 449 /** |
450 * Decode sequence header's Hypothetic Reference Decoder data | |
451 * @see 6.2.1, p32 | |
452 * @param v The VC9Context to initialize | |
453 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
454 * @return Status | |
455 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
456 static int decode_hrd(VC9Context *v, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
457 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
458 int i, num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
459 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
460 num = get_bits(gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
461 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
462 if (v->hrd_rate || num != v->hrd_num_leaky_buckets) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
463 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
464 av_freep(&v->hrd_rate); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
465 } |
2462 | 466 if (!v->hrd_rate) v->hrd_rate = av_malloc(num*sizeof(uint16_t)); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
467 if (!v->hrd_rate) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
468 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
469 if (v->hrd_buffer || num != v->hrd_num_leaky_buckets) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
470 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
471 av_freep(&v->hrd_buffer); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
472 } |
2462 | 473 if (!v->hrd_buffer) v->hrd_buffer = av_malloc(num*sizeof(uint16_t)); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
474 if (!v->hrd_buffer) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
475 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
476 v->hrd_num_leaky_buckets = num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
477 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
478 //exponent in base-2 for rate |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
479 v->bit_rate_exponent = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
480 //exponent in base-2 for buffer_size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
481 v->buffer_size_exponent = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
482 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
483 for (i=0; i<num; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
484 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
485 //mantissae, ordered (if not, use a function ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
486 v->hrd_rate[i] = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
487 if (i && v->hrd_rate[i-1]>=v->hrd_rate[i]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
488 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
489 av_log(v->s.avctx, AV_LOG_ERROR, "HDR Rates aren't strictly increasing:" |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
490 "%i vs %i\n", v->hrd_rate[i-1], v->hrd_rate[i]); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
491 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
492 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
493 v->hrd_buffer[i] = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
494 if (i && v->hrd_buffer[i-1]<v->hrd_buffer[i]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
495 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
496 av_log(v->s.avctx, AV_LOG_ERROR, "HDR Buffers aren't decreasing:" |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
497 "%i vs %i\n", v->hrd_buffer[i-1], v->hrd_buffer[i]); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
498 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
499 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
500 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
501 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
502 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
503 |
2482 | 504 /** |
505 * Decode sequence header for Advanced Profile | |
506 * @see Table 2, p18 | |
507 * @see 6.1.7, pp21-27 | |
508 * @param v The VC9Context to initialize | |
509 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
510 * @return Status | |
511 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
512 static int decode_advanced_sequence_header(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
513 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
514 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
515 int nr, dr, aspect_ratio; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
516 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
517 v->postprocflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
518 v->broadcast = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
519 v->interlace = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
520 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
521 v->tfcntrflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
522 v->finterpflag = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
523 v->panscanflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
524 v->reserved = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
525 if (v->reserved) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
526 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
527 av_log(avctx, AV_LOG_ERROR, "RESERVED should be 0 (is %i)\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
528 v->reserved); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
529 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
530 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
531 if (v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
532 v->extended_dmv = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
533 |
2462 | 534 /* 6.1.7, p21 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
535 if (get_bits(gb, 1) /* pic_size_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
536 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
537 avctx->coded_width = get_bits(gb, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
538 avctx->coded_height = get_bits(gb, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
539 if ( get_bits(gb, 1) /* disp_size_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
540 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
541 avctx->width = get_bits(gb, 14); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
542 avctx->height = get_bits(gb, 14); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
543 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
544 |
2462 | 545 /* 6.1.7.4, p22 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
546 if ( get_bits(gb, 1) /* aspect_ratio_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
547 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
548 aspect_ratio = get_bits(gb, 4); //SAR |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
549 if (aspect_ratio == 0x0F) //FF_ASPECT_EXTENDED |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
550 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
551 avctx->sample_aspect_ratio.num = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
552 avctx->sample_aspect_ratio.den = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
553 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
554 else if (aspect_ratio == 0x0E) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
555 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
556 av_log(avctx, AV_LOG_DEBUG, "Reserved AR found\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
557 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
558 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
559 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
560 avctx->sample_aspect_ratio = vc9_pixel_aspect[aspect_ratio]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
561 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
562 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
563 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
564 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
565 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
566 avctx->coded_width = avctx->width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
567 avctx->coded_height = avctx->height; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
568 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
569 |
2462 | 570 /* 6.1.8, p23 */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
571 if ( !get_bits(gb, 1) /* framerateflag */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
572 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
573 if ( get_bits(gb, 1) /* framerateind */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
574 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
575 nr = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
576 dr = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
577 if (nr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
578 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
579 av_log(avctx, AV_LOG_ERROR, "0 is forbidden for FRAMERATENR\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
580 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
581 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
582 if (nr>5) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
583 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
584 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
585 "Reserved FRAMERATENR %i not handled\n", nr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
586 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
587 if (dr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
588 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
589 av_log(avctx, AV_LOG_ERROR, "0 is forbidden for FRAMERATEDR\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
590 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
591 if (dr>2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
592 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
593 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
594 "Reserved FRAMERATEDR %i not handled\n", dr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
595 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
596 avctx->frame_rate_base = fps_nr[dr]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
597 avctx->frame_rate = fps_nr[nr]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
598 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
599 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
600 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
601 nr = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
602 // 0.03125->2048Hz / 0.03125Hz |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
603 avctx->frame_rate = 1000000; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
604 avctx->frame_rate_base = 31250*(1+nr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
605 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
606 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
607 |
2462 | 608 /* 6.1.9, p25 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
609 if ( get_bits(gb, 1) /* color_format_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
610 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
611 //Chromacity coordinates of color primaries |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
612 //like ITU-R BT.709-2, BT.470-2, ... |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
613 v->color_prim = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
614 if (v->color_prim<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
615 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
616 av_log(avctx, AV_LOG_ERROR, "0 for COLOR_PRIM is reserved\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
617 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
618 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
619 if (v->color_prim == 3 || v->color_prim>6) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
620 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
621 av_log(avctx, AV_LOG_DEBUG, "Reserved COLOR_PRIM %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
622 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
623 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
624 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
625 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
626 //Opto-electronic transfer characteristics |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
627 v->transfer_char = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
628 if (v->transfer_char == 3 || v->transfer_char>8) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
629 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
630 av_log(avctx, AV_LOG_DEBUG, "Reserved TRANSFERT_CHAR %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
631 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
632 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
633 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
634 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
635 //Matrix coefficient for primariev->YCbCr |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
636 v->matrix_coef = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
637 if (v->matrix_coef < 1) return -1; //forbidden |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
638 if ((v->matrix_coef>3 && v->matrix_coef<6) || v->matrix_coef>7) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
639 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
640 av_log(avctx, AV_LOG_DEBUG, "Reserved MATRIX_COEF %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
641 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
642 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
643 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
644 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
645 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
646 //Hypothetical reference decoder indicator flag |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
647 v->hrd_param_flag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
648 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
649 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
650 if (decode_hrd(v, gb) < 0) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
651 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
652 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
653 av_log(avctx, AV_LOG_DEBUG, "Advanced profile not supported yet\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
654 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
655 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
656 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
657 |
2482 | 658 /** |
659 * Decode Simple/Main Profiles sequence header | |
660 * @see Figure 7-8, p16-17 | |
661 * @param avctx Codec context | |
662 * @param gb GetBit context initialized from Codec context extra_data | |
663 * @return Status | |
664 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
665 static int decode_sequence_header(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
666 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
667 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
668 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
669 v->profile = get_bits(gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
670 av_log(avctx, AV_LOG_DEBUG, "Profile: %i\n", v->profile); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
671 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
672 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
673 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
674 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
675 v->level = get_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
676 v->chromaformat = get_bits(gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
677 if (v->chromaformat != 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
678 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
679 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
680 "Only 4:2:0 chroma format supported\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
681 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
682 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
683 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
684 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
685 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
686 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
687 v->res_sm = get_bits(gb, 2); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
688 if (v->res_sm) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
689 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
690 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
691 "Reserved RES_SM=%i is forbidden\n", v->res_sm); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
692 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
693 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
694 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
695 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
696 // (fps-2)/4 (->30) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
697 v->frmrtq_postproc = get_bits(gb, 3); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
698 // (bitrate-32kbps)/64kbps |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
699 v->bitrtq_postproc = get_bits(gb, 5); //common |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
700 v->s.loop_filter = get_bits(gb, 1); //common |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
701 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
702 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
703 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
704 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
705 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
706 v->res_x8 = get_bits(gb, 1); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
707 if (v->res_x8) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
708 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
709 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
710 "1 for reserved RES_X8 is forbidden\n"); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
711 //return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
712 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
713 v->multires = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
714 v->res_fasttx = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
715 if (!v->res_fasttx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
716 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
717 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
718 "0 for reserved RES_FASTTX is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
719 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
720 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
721 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
722 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
723 v->fastuvmc = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
724 if (!v->profile && !v->fastuvmc) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
725 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
726 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
727 "FASTUVMC unavailable in Simple Profile\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
728 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
729 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
730 v->extended_mv = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
731 if (!v->profile && v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
732 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
733 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
734 "Extended MVs unavailable in Simple Profile\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
735 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
736 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
737 v->dquant = get_bits(gb, 2); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
738 v->vstransform = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
739 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
740 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
741 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
742 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
743 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
744 v->res_transtab = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
745 if (v->res_transtab) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
746 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
747 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
748 "1 for reserved RES_TRANSTAB is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
749 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
750 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
751 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
752 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
753 v->overlap = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
754 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
755 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
756 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
757 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
758 { |
2474 | 759 v->s.resync_marker = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
760 v->rangered = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
761 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
762 |
2474 | 763 v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
764 v->quantizer_mode = get_bits(gb, 2); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
765 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
766 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
767 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
768 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
769 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
770 v->finterpflag = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
771 v->res_rtm_flag = get_bits(gb, 1); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
772 if (!v->res_rtm_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
773 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
774 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
775 "0 for reserved RES_RTM_FLAG is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
776 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
777 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
778 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
779 av_log(avctx, AV_LOG_INFO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
780 "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
781 "LoopFilter=%i, MultiRes=%i, FastUVMV=%i, Extended MV=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
782 "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
783 "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
784 v->profile, v->frmrtq_postproc, v->bitrtq_postproc, |
2482 | 785 v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, |
2474 | 786 v->rangered, v->vstransform, v->overlap, v->s.resync_marker, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
787 v->dquant, v->quantizer_mode, avctx->max_b_frames |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
788 ); |
2462 | 789 return 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
790 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
791 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
792 #if HAS_ADVANCED_PROFILE |
2462 | 793 else return decode_advanced_sequence_header(avctx, gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
794 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
795 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
796 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
797 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
798 #if HAS_ADVANCED_PROFILE |
2482 | 799 /** Entry point decoding (Advanced Profile) |
800 * @param avctx Codec context | |
801 * @param gb GetBit context initialized from avctx->extra_data | |
802 * @return Status | |
803 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
804 static int advanced_entry_point_process(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
805 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
806 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
807 int range_mapy_flag, range_mapuv_flag, i; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
808 if (v->profile != PROFILE_ADVANCED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
809 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
810 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
811 "Entry point are only defined in Advanced Profile!\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
812 return -1; //Only for advanced profile! |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
813 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
814 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
815 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
816 //Update buffer fullness |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
817 av_log(avctx, AV_LOG_DEBUG, "Buffer fullness update\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
818 for (i=0; i<v->hrd_num_leaky_buckets; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
819 skip_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
820 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
821 if ((range_mapy_flag = get_bits(gb, 1))) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
822 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
823 //RANGE_MAPY |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
824 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPY\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
825 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
826 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
827 if ((range_mapuv_flag = get_bits(gb, 1))) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
828 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
829 //RANGE_MAPUV |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
830 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPUV\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
831 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
832 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
833 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
834 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
835 //NUMPANSCANWIN |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
836 v->numpanscanwin = get_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
837 av_log(avctx, AV_LOG_DEBUG, "NUMPANSCANWIN: %u\n", v->numpanscanwin); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
838 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
839 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
840 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
841 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
842 |
2482 | 843 /***********************************************************************/ |
844 /** | |
845 * @defgroup bitplane VC9 Bitplane decoding | |
846 * @see 8.7, p56 | |
847 * @{ | |
848 */ | |
849 | |
850 /** @addtogroup bitplane | |
851 * Imode types | |
852 * @{ | |
853 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
854 #define IMODE_RAW 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
855 #define IMODE_NORM2 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
856 #define IMODE_DIFF2 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
857 #define IMODE_NORM6 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
858 #define IMODE_DIFF6 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
859 #define IMODE_ROWSKIP 5 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
860 #define IMODE_COLSKIP 6 |
2482 | 861 /** @} */ //imode defines |
862 | |
863 /** Allocate the buffer from a bitplane, given its dimensions | |
864 * @param bp Bitplane which buffer is to allocate | |
865 * @param[in] width Width of the buffer | |
866 * @param[in] height Height of the buffer | |
867 * @return Status | |
868 * @todo TODO: Take into account stride | |
869 * @todo TODO: Allow use of external buffers ? | |
870 */ | |
2462 | 871 int alloc_bitplane(BitPlane *bp, int width, int height) |
872 { | |
873 if (!bp || bp->width<0 || bp->height<0) return -1; | |
874 bp->data = (uint8_t*)av_malloc(width*height); | |
875 if (!bp->data) return -1; | |
2482 | 876 bp->width = bp->stride = width; |
2462 | 877 bp->height = height; |
878 return 0; | |
879 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
880 |
2482 | 881 /** Free the bitplane's buffer |
882 * @param bp Bitplane which buffer is to free | |
883 */ | |
2474 | 884 void free_bitplane(BitPlane *bp) |
885 { | |
886 bp->width = bp->stride = bp->height = 0; | |
887 if (bp->data) av_freep(&bp->data); | |
888 } | |
889 | |
2482 | 890 /** Decode rows by checking if they are skiped |
891 * @param plane Buffer to store decoded bits | |
892 * @param[in] width Width of this buffer | |
893 * @param[in] height Height of this buffer | |
894 * @param[in] stride of this buffer | |
895 */ | |
2459 | 896 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ |
897 int x, y; | |
2474 | 898 GetBitContext *gb = &v->s.gb; |
2459 | 899 |
900 for (y=0; y<height; y++){ | |
2474 | 901 if (!get_bits(gb, 1)) //rowskip |
2459 | 902 memset(plane, 0, width); |
903 else | |
904 for (x=0; x<width; x++) | |
2474 | 905 plane[x] = get_bits(gb, 1); |
2459 | 906 plane += stride; |
907 } | |
908 } | |
909 | |
2482 | 910 /** Decode columns by checking if they are skiped |
911 * @param plane Buffer to store decoded bits | |
912 * @param[in] width Width of this buffer | |
913 * @param[in] height Height of this buffer | |
914 * @param[in] stride of this buffer | |
915 * @fixme FIXME: Optimize | |
916 */ | |
2459 | 917 static void decode_colskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ |
918 int x, y; | |
2474 | 919 GetBitContext *gb = &v->s.gb; |
2459 | 920 |
921 for (x=0; x<width; x++){ | |
2474 | 922 if (!get_bits(gb, 1)) //colskip |
2459 | 923 for (y=0; y<height; y++) |
924 plane[y*stride] = 0; | |
925 else | |
926 for (y=0; y<height; y++) | |
2474 | 927 plane[y*stride] = get_bits(gb, 1); |
2459 | 928 plane ++; |
929 } | |
930 } | |
931 | |
2482 | 932 /** Decode a bitplane's bits |
933 * @param bp Bitplane where to store the decode bits | |
934 * @param v VC9 context for bit reading and logging | |
935 * @return Status | |
936 * @fixme FIXME: Optimize | |
937 * @todo TODO: Decide if a struct is needed | |
938 */ | |
2462 | 939 static int bitplane_decoding(BitPlane *bp, VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
940 { |
2474 | 941 GetBitContext *gb = &v->s.gb; |
942 | |
2462 | 943 int imode, x, y, code, use_vertical_tile, tile_w, tile_h; |
944 uint8_t invert, *planep = bp->data; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
945 |
2474 | 946 invert = get_bits(gb, 1); |
947 imode = get_vlc2(gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
948 |
2462 | 949 bp->is_raw = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
950 switch (imode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
951 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
952 case IMODE_RAW: |
2462 | 953 //Data is actually read in the MB layer (same for all tests == "raw") |
954 bp->is_raw = 1; //invert ignored | |
955 return invert; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
956 case IMODE_DIFF2: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
957 case IMODE_NORM2: |
2474 | 958 if ((bp->height*bp->width) & 1) *(++planep) = get_bits(gb, 1); |
2462 | 959 for(x=0; x<(bp->height*bp->width)>>1; x++){ |
2474 | 960 code = get_vlc2(gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); |
2459 | 961 *(++planep) = code&1; //lsb => left |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
962 *(++planep) = (code>>1)&1; //msb => right |
2459 | 963 //FIXME width->stride |
964 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
965 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
966 case IMODE_DIFF6: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
967 case IMODE_NORM6: |
2462 | 968 use_vertical_tile= bp->height%3==0 && bp->width%3!=0; |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
969 tile_w= use_vertical_tile ? 2 : 3; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
970 tile_h= use_vertical_tile ? 3 : 2; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
971 |
2462 | 972 for(y= bp->height%tile_h; y< bp->height; y+=tile_h){ |
973 for(x= bp->width%tile_w; x< bp->width; x+=tile_w){ | |
2482 | 974 #if VLC_NORM6_METH0D == 1 |
2474 | 975 code = get_vlc2(gb, vc9_norm6_vlc.table, VC9_NORM6_VLC_BITS, 2); |
2463
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
976 if(code<0){ |
2482 | 977 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); |
2463
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
978 return -1; |
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
979 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
980 #endif |
2482 | 981 #if VLC_NORM6_METH0D == 2 //Failure |
982 code = get_vlc2(gb, vc9_norm6_first_vlc.table, VC9_NORM6_FIRST_BITS, 2); | |
983 if (code == 22) | |
984 { | |
985 code = vc9_norm6_flc_val[get_bits(gb, 5)]; | |
986 } | |
987 else if (code == 23) | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
988 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
989 # if TRACE |
2482 | 990 code = get_vlc2(gb, vc9_norm6_second_vlc.table, VC9_NORM6_SECOND_BITS, 2); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
991 assert(code>-1 && code<22); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
992 code = vc9_norm6_second_val[code]; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
993 # else |
2482 | 994 code = vc9_norm6_second_val[get_vlc2(gb, vc9_norm6_second_vlc.table, VC9_NORM6_SECOND_BITS, 2)]; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
995 # endif |
2482 | 996 } |
997 #endif //VLC_NORM6_METH0D == 2 | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
998 //FIXME following is a pure guess and probably wrong |
2462 | 999 //FIXME A bitplane (0 | !0), so could the shifts be avoided ? |
1000 planep[x + 0*bp->stride]= (code>>0)&1; | |
1001 planep[x + 1 + 0*bp->stride]= (code>>1)&1; | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1002 //FIXME Does branch prediction help here? |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1003 if(use_vertical_tile){ |
2462 | 1004 planep[x + 0 + 1*bp->stride]= (code>>2)&1; |
1005 planep[x + 1 + 1*bp->stride]= (code>>3)&1; | |
1006 planep[x + 0 + 2*bp->stride]= (code>>4)&1; | |
1007 planep[x + 1 + 2*bp->stride]= (code>>5)&1; | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1008 }else{ |
2462 | 1009 planep[x + 2 + 0*bp->stride]= (code>>2)&1; |
1010 planep[x + 0 + 1*bp->stride]= (code>>3)&1; | |
1011 planep[x + 1 + 1*bp->stride]= (code>>4)&1; | |
1012 planep[x + 2 + 1*bp->stride]= (code>>5)&1; | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1013 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1014 } |
2459 | 1015 } |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1016 |
2462 | 1017 x= bp->width % tile_w; |
1018 decode_colskip(bp->data , x, bp->height , bp->stride, v); | |
1019 decode_rowskip(bp->data+x, bp->width - x, bp->height % tile_h, bp->stride, v); | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1020 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1021 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1022 case IMODE_ROWSKIP: |
2462 | 1023 decode_rowskip(bp->data, bp->width, bp->height, bp->stride, v); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1024 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1025 case IMODE_COLSKIP: //Teh ugly |
2462 | 1026 decode_colskip(bp->data, bp->width, bp->height, bp->stride, v); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1027 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1028 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1029 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1030 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1031 /* Applying diff operator */ |
2459 | 1032 if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1033 { |
2462 | 1034 planep = bp->data; |
2459 | 1035 planep[0] ^= invert; |
2462 | 1036 for (x=1; x<bp->width; x++) |
2459 | 1037 planep[x] ^= planep[x-1]; |
2462 | 1038 for (y=1; y<bp->height; y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1039 { |
2462 | 1040 planep += bp->stride; |
1041 planep[0] ^= planep[-bp->stride]; | |
1042 for (x=1; x<bp->width; x++) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1043 { |
2462 | 1044 if (planep[x-1] != planep[x-bp->stride]) planep[x] ^= invert; |
1045 else planep[x] ^= planep[x-1]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1046 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1047 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1048 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1049 else if (invert) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1050 { |
2462 | 1051 planep = bp->data; |
1052 for (x=0; x<bp->width*bp->height; x++) planep[x] = !planep[x]; //FIXME stride | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1053 } |
2462 | 1054 return (imode<<1) + invert; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1055 } |
2482 | 1056 /** @} */ //Bitplane group |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1057 |
2482 | 1058 /***********************************************************************/ |
1059 /** VOP Dquant decoding | |
1060 * @param v VC9 Context | |
1061 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1062 static int vop_dquant_decoding(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1063 { |
2474 | 1064 GetBitContext *gb = &v->s.gb; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1065 int pqdiff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1066 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1067 //variable size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1068 if (v->dquant == 2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1069 { |
2474 | 1070 pqdiff = get_bits(gb, 3); |
1071 if (pqdiff == 7) v->altpq = get_bits(gb, 5); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1072 else v->altpq = v->pq + pqdiff + 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1073 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1074 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1075 { |
2474 | 1076 v->dquantfrm = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1077 if ( v->dquantfrm ) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1078 { |
2474 | 1079 v->dqprofile = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1080 switch (v->dqprofile) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1081 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1082 case DQPROFILE_SINGLE_EDGE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1083 case DQPROFILE_DOUBLE_EDGES: |
2474 | 1084 v->dqsbedge = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1085 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1086 case DQPROFILE_ALL_MBS: |
2474 | 1087 v->dqbilevel = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1088 default: break; //Forbidden ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1089 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1090 if (!v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1091 { |
2474 | 1092 pqdiff = get_bits(gb, 3); |
1093 if (pqdiff == 7) v->altpq = get_bits(gb, 5); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1094 else v->altpq = v->pq + pqdiff + 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1095 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1096 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1097 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1098 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1099 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1100 |
2482 | 1101 /***********************************************************************/ |
1102 /** | |
1103 * @defgroup all_frame_hdr All VC9 profiles frame header | |
1104 * @brief Part of the frame header decoding from all profiles | |
1105 * @warning Only pro/epilog differs between Simple/Main and Advanced => check caller | |
1106 * @{ | |
1107 */ | |
1108 /** B and BI frame header decoding, primary part | |
1109 * @see Tables 11+12, p62-65 | |
1110 * @param v VC9 context | |
1111 * @return Status | |
1112 * @warning Also handles BI frames | |
1113 */ | |
2474 | 1114 static int decode_b_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1115 { |
2474 | 1116 GetBitContext *gb = &v->s.gb; |
2483 | 1117 int pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1118 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1119 /* Prolog common to all frametypes should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1120 if (v->profile == PROFILE_SIMPLE) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1121 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1122 av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1123 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1124 } |
2474 | 1125 v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1126 VC9_BFRACTION_VLC_BITS, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1127 if (v->bfraction < -1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1128 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1129 av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1130 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1131 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1132 else if (!v->bfraction) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1133 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1134 /* We actually have a BI frame */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1135 v->s.pict_type = BI_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1136 v->buffer_fullness = get_bits(gb, 7); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1137 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1138 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1139 /* Read the quantization stuff */ |
2474 | 1140 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1141 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1142 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1143 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1144 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1145 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1146 } |
2474 | 1147 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1148 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1149 v->pquantizer = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1150 |
2483 | 1151 if (v->profile > PROFILE_MAIN) |
1152 { | |
1153 if (v->postprocflag) v->postproc = get_bits(gb, 2); | |
1154 if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE) | |
1155 v->mvrange = get_prefix(gb, 0, 3); | |
1156 } | |
1157 else | |
1158 { | |
1159 if (v->extended_mv == 1) | |
1160 v->mvrange = get_prefix(gb, 0, 3); | |
1161 } | |
1162 /* Read the MV mode */ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1163 if (v->s.pict_type != BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1164 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1165 v->mv_mode = get_bits(gb, 1); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1166 if (v->pq < 13) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1167 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1168 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1169 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1170 v->mv_mode = get_bits(gb, 2); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1171 if (v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1172 av_log(v->s.avctx, AV_LOG_ERROR, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1173 "mv_mode for lowquant B frame was %i\n", v->mv_mode); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1174 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1175 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1176 else |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1177 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1178 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1179 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1180 if (get_bits(gb, 1)) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1181 av_log(v->s.avctx, AV_LOG_ERROR, |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1182 "mv_mode for highquant B frame was %i\n", v->mv_mode); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1183 } |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1184 v->mv_mode = 1-v->mv_mode; //To match (pq < 13) mapping |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1185 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1186 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1187 |
2474 | 1188 return 0; |
1189 } | |
1190 | |
2482 | 1191 /** B and BI frame header decoding, secondary part |
1192 * @see Tables 11+12, p62-65 | |
1193 * @param v VC9 context | |
1194 * @return Status | |
1195 * @warning Also handles BI frames | |
1196 * @warning To call once all MB arrays are allocated | |
2483 | 1197 * @todo Support Advanced Profile headers |
2482 | 1198 */ |
2474 | 1199 static int decode_b_picture_secondary_header(VC9Context *v) |
1200 { | |
1201 GetBitContext *gb = &v->s.gb; | |
1202 int status; | |
1203 | |
2483 | 1204 status = bitplane_decoding(&v->skip_mb_plane, v); |
2474 | 1205 if (status < 0) return -1; |
1206 #if TRACE | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1207 if (v->mv_mode == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1208 { |
2462 | 1209 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1210 if (status < 0) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1211 return -1; |
2462 | 1212 #if TRACE |
2474 | 1213 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1214 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1215 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1216 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1217 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1218 //bitplane |
2462 | 1219 status = bitplane_decoding(&v->direct_mb_plane, v); |
1220 if (status < 0) return -1; | |
1221 #if TRACE | |
2474 | 1222 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct plane encoding: " |
2462 | 1223 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1224 #endif | |
1225 | |
2474 | 1226 av_log(v->s.avctx, AV_LOG_DEBUG, "Skip MB plane encoding: " |
2462 | 1227 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1228 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1229 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1230 /* FIXME: what is actually chosen for B frames ? */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1231 v->s.mv_table_index = get_bits(gb, 2); //but using vc9_ tables |
2474 | 1232 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)]; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1233 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1234 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1235 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1236 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1237 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1238 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1239 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1240 { |
2474 | 1241 v->ttmbf = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1242 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1243 { |
2474 | 1244 v->ttfrm = get_bits(gb, 2); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1245 av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n", |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1246 (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1247 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1248 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1249 /* Epilog (AC/DC syntax) should be done in caller */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1250 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1251 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1252 |
2482 | 1253 /** I frame header decoding, primary part |
1254 * @see Tables 5+7, p53-54 and 55-57 | |
1255 * @param v VC9 context | |
1256 * @return Status | |
2483 | 1257 * @todo Support Advanced Profile headers |
2482 | 1258 */ |
2483 | 1259 static int decode_i_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1260 { |
2474 | 1261 GetBitContext *gb = &v->s.gb; |
2483 | 1262 int pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1263 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1264 /* Prolog common to all frametypes should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1265 //BF = Buffer Fullness |
2474 | 1266 if (v->profile <= PROFILE_MAIN && get_bits(gb, 7)) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1267 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1268 av_log(v->s.avctx, AV_LOG_DEBUG, "I BufferFullness not 0\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1269 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1270 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1271 /* Quantizer stuff */ |
2474 | 1272 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1273 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1274 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1275 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1276 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1277 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1278 } |
2474 | 1279 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1280 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1281 v->pquantizer = get_bits(gb, 1); |
1282 av_log(v->s.avctx, AV_LOG_DEBUG, "I frame: QP=%i (+%i/2)\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1283 v->pq, v->halfpq); |
2483 | 1284 return 0; |
1285 } | |
1286 | |
1287 /** I frame header decoding, secondary part | |
1288 * @param v VC9 context | |
1289 * @return Status | |
1290 * @todo Support Advanced Profile headers | |
1291 */ | |
1292 static int decode_i_picture_secondary_header(VC9Context *v) | |
1293 { | |
1294 int status; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1295 #if HAS_ADVANCED_PROFILE |
2483 | 1296 if (v->profile > PROFILE_MAIN) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1297 { |
2483 | 1298 v->s.ac_pred = get_bits(&v->s.gb, 1); |
1299 if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1300 /* 7.1.1.34 + 8.5.2 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1301 if (v->overlap && v->pq<9) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1302 { |
2483 | 1303 v->condover = get_bits(&v->s.gb, 1); |
2462 | 1304 if (v->condover) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1305 { |
2483 | 1306 v->condover = 2+get_bits(&v->s.gb, 1); |
2462 | 1307 if (v->condover == 3) |
1308 { | |
1309 status = bitplane_decoding(&v->over_flags_plane, v); | |
1310 if (status < 0) return -1; | |
2483 | 1311 # if TRACE |
2474 | 1312 av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: " |
2462 | 1313 "Imode: %i, Invert: %i\n", status>>1, status&1); |
2483 | 1314 # endif |
2462 | 1315 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1316 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1317 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1318 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1319 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1320 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1321 /* Epilog (AC/DC syntax) should be done in caller */ |
2483 | 1322 return 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1323 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1324 |
2482 | 1325 /** P frame header decoding, primary part |
1326 * @see Tables 5+7, p53-54 and 55-57 | |
1327 * @param v VC9 context | |
2483 | 1328 * @todo Support Advanced Profile headers |
2482 | 1329 * @return Status |
1330 */ | |
2474 | 1331 static int decode_p_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1332 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1333 /* INTERFRM, FRMCNT, RANGEREDFRM read in caller */ |
2474 | 1334 GetBitContext *gb = &v->s.gb; |
2483 | 1335 int lowquant, pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1336 |
2474 | 1337 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1338 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1339 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1340 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1341 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1342 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1343 } |
2474 | 1344 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1345 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1346 v->pquantizer = get_bits(gb, 1); |
1347 av_log(v->s.avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1348 v->pq, v->halfpq); |
2474 | 1349 if (v->extended_mv == 1) v->mvrange = get_prefix(gb, 0, 3); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1350 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1351 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1352 { |
2474 | 1353 if (v->postprocflag) v->postproc = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1354 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1355 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1356 #endif |
2474 | 1357 if (v->multires) v->respic = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1358 lowquant = (v->pquantizer>12) ? 0 : 1; |
2474 | 1359 v->mv_mode = mv_pmode_table[lowquant][get_prefix(gb, 1, 4)]; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1360 if (v->mv_mode == MV_PMODE_INTENSITY_COMP) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1361 { |
2474 | 1362 v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(gb, 1, 3)]; |
1363 v->lumscale = get_bits(gb, 6); | |
1364 v->lumshift = get_bits(gb, 6); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1365 } |
2474 | 1366 return 0; |
1367 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1368 |
2482 | 1369 /** P frame header decoding, secondary part |
1370 * @see Tables 5+7, p53-54 and 55-57 | |
1371 * @param v VC9 context | |
1372 * @warning To call once all MB arrays are allocated | |
1373 * @return Status | |
1374 */ | |
2474 | 1375 static int decode_p_picture_secondary_header(VC9Context *v) |
1376 { | |
1377 GetBitContext *gb = &v->s.gb; | |
1378 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1379 if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1380 v->mv_mode2 == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1381 || v->mv_mode == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1382 { |
2462 | 1383 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1384 if (status < 0) return -1; | |
1385 #if TRACE | |
2474 | 1386 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1387 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1388 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1389 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1390 |
2462 | 1391 status = bitplane_decoding(&v->skip_mb_plane, v); |
1392 if (status < 0) return -1; | |
1393 #if TRACE | |
2474 | 1394 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " |
2462 | 1395 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1396 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1397 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1398 /* Hopefully this is correct for P frames */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1399 v->s.mv_table_index =get_bits(gb, 2); //but using vc9_ tables |
2474 | 1400 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)]; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1401 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1402 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1403 { |
2474 | 1404 av_log(v->s.avctx, AV_LOG_INFO, "VOP DQuant info\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1405 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1406 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1407 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1408 v->ttfrm = 0; //FIXME Is that so ? |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1409 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1410 { |
2474 | 1411 v->ttmbf = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1412 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1413 { |
2474 | 1414 v->ttfrm = get_bits(gb, 2); |
1415 av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1416 (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1417 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1418 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1419 /* Epilog (AC/DC syntax) should be done in caller */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1420 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1421 } |
2482 | 1422 /** @} */ //End of group all_frm_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1423 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1424 |
2482 | 1425 /***********************************************************************/ |
1426 /** | |
1427 * @defgroup std_frame_hdr VC9 Simple/Main Profiles header decoding | |
1428 * @brief Part of the frame header decoding belonging to Simple/Main Profiles | |
1429 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1430 * check caller | |
1431 * @{ | |
1432 */ | |
1433 | |
1434 /** Frame header decoding, first part, in Simple and Main profiles | |
1435 * @see Tables 5+7, p53-54 and 55-57 | |
1436 * @param v VC9 context | |
2483 | 1437 * @todo FIXME: RANGEREDFRM element not read if BI frame from Table6, P54 |
1438 * However, 7.1.1.8 says "all frame types, for main profiles" | |
2482 | 1439 * @return Status |
1440 */ | |
2474 | 1441 static int standard_decode_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1442 { |
2474 | 1443 GetBitContext *gb = &v->s.gb; |
1444 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1445 |
2474 | 1446 if (v->finterpflag) v->interpfrm = get_bits(gb, 1); |
1447 skip_bits(gb, 2); //framecnt unused | |
1448 if (v->rangered) v->rangeredfrm = get_bits(gb, 1); | |
1449 v->s.pict_type = get_bits(gb, 1); | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1450 if (v->s.avctx->max_b_frames) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1451 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1452 if (!v->s.pict_type) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1453 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1454 if (get_bits(gb, 1)) v->s.pict_type = I_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1455 else v->s.pict_type = B_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1456 } |
2474 | 1457 else v->s.pict_type = P_TYPE; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1458 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1459 else v->s.pict_type++; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1460 |
2474 | 1461 switch (v->s.pict_type) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1462 { |
2483 | 1463 case I_TYPE: status = decode_i_picture_primary_header(v); break; |
2474 | 1464 case P_TYPE: status = decode_p_picture_primary_header(v); break; |
2483 | 1465 case BI_TYPE: //Same as B |
2474 | 1466 case B_TYPE: status = decode_b_picture_primary_header(v); break; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1467 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1468 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1469 if (status == FRAME_SKIPED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1470 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1471 av_log(v->s.avctx, AV_LOG_INFO, "Skipping frame...\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1472 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1473 } |
2474 | 1474 return 0; |
1475 } | |
1476 | |
2482 | 1477 /** Frame header decoding, secondary part |
1478 * @param v VC9 context | |
1479 * @warning To call once all MB arrays are allocated | |
1480 * @return Status | |
1481 */ | |
2474 | 1482 static int standard_decode_picture_secondary_header(VC9Context *v) |
1483 { | |
1484 GetBitContext *gb = &v->s.gb; | |
1485 int status = 0, index; | |
1486 | |
1487 switch (v->s.pict_type) | |
1488 { | |
1489 case P_TYPE: status = decode_p_picture_secondary_header(v); break; | |
1490 case B_TYPE: status = decode_b_picture_secondary_header(v); break; | |
2483 | 1491 case BI_TYPE: |
1492 case I_TYPE: break; //Nothing needed as it's done in the epilog | |
2474 | 1493 } |
2483 | 1494 if (status < 0) return FRAME_SKIPED; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1495 |
2462 | 1496 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1497 v->ac_table_level = decode012(gb); |
2474 | 1498 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1499 { |
2482 | 1500 v->ac2_table_level = decode012(gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1501 } |
2462 | 1502 /* DC Syntax */ |
2474 | 1503 index = decode012(gb); |
1504 v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index]; | |
1505 v->chroma_dc_vlc = &ff_msmp4_dc_chroma_vlc[index]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1506 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1507 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1508 } |
2482 | 1509 /** @} */ //End for group std_frame_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1510 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1511 #if HAS_ADVANCED_PROFILE |
2482 | 1512 /***********************************************************************/ |
1513 /** | |
1514 * @defgroup adv_frame_hdr VC9 Advanced Profile header decoding | |
1515 * @brief Part of the frame header decoding belonging to Advanced Profiles | |
1516 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1517 * check caller | |
1518 * @{ | |
1519 */ | |
1520 /** Frame header decoding, primary part | |
1521 * @param v VC9 context | |
1522 * @return Status | |
1523 */ | |
2474 | 1524 static int advanced_decode_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1525 { |
2474 | 1526 GetBitContext *gb = &v->s.gb; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1527 static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE }; |
2483 | 1528 int type; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1529 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1530 if (v->interlace) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1531 { |
2474 | 1532 v->fcm = get_bits(gb, 1); |
1533 if (v->fcm) v->fcm = 2+get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1534 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1535 |
2474 | 1536 type = get_prefix(gb, 0, 4); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1537 if (type > 4 || type < 0) return FRAME_SKIPED; |
2474 | 1538 v->s.pict_type = type_table[type]; |
1539 av_log(v->s.avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->s.pict_type); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1540 |
2474 | 1541 if (v->tfcntrflag) v->tfcntr = get_bits(gb, 8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1542 if (v->broadcast) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1543 { |
2474 | 1544 if (!v->interlace) v->rptfrm = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1545 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1546 { |
2474 | 1547 v->tff = get_bits(gb, 1); |
1548 v->rff = get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1549 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1550 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1551 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1552 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1553 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1554 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1555 for (i=0; i<v->numpanscanwin; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1556 { |
2474 | 1557 v->topleftx[i] = get_bits(gb, 16); |
1558 v->toplefty[i] = get_bits(gb, 16); | |
1559 v->bottomrightx[i] = get_bits(gb, 16); | |
1560 v->bottomrighty[i] = get_bits(gb, 16); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1561 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1562 #else |
2474 | 1563 skip_bits(gb, 16*4*v->numpanscanwin); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1564 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1565 } |
2474 | 1566 v->s.no_rounding = !get_bits(gb, 1); |
1567 v->uvsamp = get_bits(gb, 1); | |
1568 if (v->finterpflag == 1) v->interpfrm = get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1569 |
2474 | 1570 switch(v->s.pict_type) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1571 { |
2483 | 1572 case I_TYPE: if (decode_i_picture_primary_header(v) < 0) return -1; |
2474 | 1573 case P_TYPE: if (decode_p_picture_primary_header(v) < 0) return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1574 case BI_TYPE: |
2474 | 1575 case B_TYPE: if (decode_b_picture_primary_header(v) < 0) return FRAME_SKIPED; |
2483 | 1576 default: return -1; |
2474 | 1577 } |
1578 } | |
1579 | |
2482 | 1580 /** Frame header decoding, secondary part |
1581 * @param v VC9 context | |
1582 * @return Status | |
1583 */ | |
2474 | 1584 static int advanced_decode_picture_secondary_header(VC9Context *v) |
1585 { | |
1586 GetBitContext *gb = &v->s.gb; | |
2483 | 1587 int index, status = 0; |
2474 | 1588 |
1589 switch(v->s.pict_type) | |
1590 { | |
2483 | 1591 case P_TYPE: status = decode_p_picture_secondary_header(v); break; |
1592 case B_TYPE: status = decode_b_picture_secondary_header(v); break; | |
1593 case BI_TYPE: | |
1594 case I_TYPE: status = decode_i_picture_secondary_header(v); break; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1595 } |
2483 | 1596 if (status<0) return FRAME_SKIPED; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1597 |
2462 | 1598 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1599 v->ac_table_level = decode012(gb); |
2474 | 1600 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1601 { |
2482 | 1602 v->ac2_table_level = decode012(gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1603 } |
2462 | 1604 /* DC Syntax */ |
2474 | 1605 index = decode012(gb); |
1606 v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index]; | |
1607 v->chroma_dc_vlc = &ff_msmp4_dc_chroma_vlc[index]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1608 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1609 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1610 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1611 #endif |
2482 | 1612 /** @} */ //End for adv_frame_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1613 |
2482 | 1614 /***********************************************************************/ |
1615 /** | |
1616 * @defgroup block VC9 Block-level functions | |
1617 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 | |
1618 * @todo TODO: Integrate to MpegEncContext facilities | |
1619 * @{ | |
1620 */ | |
1621 /** Decode a luma intra block | |
1622 * @warning Will be removed, due to necessary integration | |
1623 * @see coeff scaling for Adv Profile: 8.1.1.15, p(1)13, | |
1624 * @param v VC9 context | |
1625 * @param mquant Macroblock quantizer scale | |
1626 * @return Status | |
1627 * @todo TODO: Implement Coeff scaling for Advanced Profile | |
1628 */ | |
2462 | 1629 int decode_luma_intra_block(VC9Context *v, int mquant) |
1630 { | |
2474 | 1631 GetBitContext *gb = &v->s.gb; |
2462 | 1632 int dcdiff; |
1633 | |
2474 | 1634 dcdiff = get_vlc2(gb, v->luma_dc_vlc->table, |
1635 DC_VLC_BITS, 2); | |
2462 | 1636 if (dcdiff) |
1637 { | |
1638 if (dcdiff == 119 /* ESC index value */) | |
1639 { | |
1640 /* TODO: Optimize */ | |
2474 | 1641 if (mquant == 1) dcdiff = get_bits(gb, 10); |
1642 else if (mquant == 2) dcdiff = get_bits(gb, 9); | |
1643 else dcdiff = get_bits(gb, 8); | |
2462 | 1644 } |
1645 else | |
1646 { | |
1647 if (mquant == 1) | |
2474 | 1648 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
2462 | 1649 else if (mquant == 2) |
2474 | 1650 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; |
2462 | 1651 } |
2474 | 1652 if (get_bits(gb, 1)) |
2462 | 1653 dcdiff = -dcdiff; |
1654 } | |
1655 /* FIXME: 8.1.1.15, p(1)13, coeff scaling for Adv Profile */ | |
1656 | |
1657 return 0; | |
1658 } | |
2482 | 1659 /** @} */ //End for group block |
2462 | 1660 |
2482 | 1661 /***********************************************************************/ |
1662 /** | |
1663 * @defgroup std_mb VC9 Macroblock-level functions in Simple/Main Profiles | |
1664 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 | |
1665 * @todo TODO: Integrate to MpegEncContext facilities | |
1666 * @{ | |
1667 */ | |
1668 /** | |
1669 * @def GET_CBPCY(table, bits) | |
1670 * @brief Get the Coded Block Pattern for luma and chroma | |
1671 * @param table VLC table to use (get_vlc2 second parameter) | |
1672 * @param bits Average bitlength (third parameter to get_vlc2) | |
1673 * @see 8.1.1.5, p(1)02-(1)03 | |
1674 */ | |
2462 | 1675 #define GET_CBPCY(table, bits) \ |
2474 | 1676 predicted_cbpcy = get_vlc2(gb, table, bits, 2); \ |
2462 | 1677 cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) \ |
1678 ? previous_cbpcy[1] : p_cbpcy[+2]; \ | |
1679 cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01); \ | |
1680 cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3]; \ | |
1681 cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01); \ | |
1682 cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) \ | |
1683 ? previous_cbpcy[3] : cbpcy[0]; \ | |
1684 cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01); \ | |
1685 cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1]; \ | |
1686 cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01); | |
1687 | |
2482 | 1688 /** Decode all MBs for an I frame in Simple/Main profile |
1689 * @see 8.1, p100 | |
1690 * @todo TODO: Process the blocks | |
1691 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1692 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1693 static int standard_decode_i_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1694 { |
2474 | 1695 GetBitContext *gb = &v->s.gb; |
1696 MpegEncContext *s = &v->s; | |
1697 int current_mb = 0; /* MB/Block Position info */ | |
2462 | 1698 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
1699 *p_cbpcy /* Pointer to skip some math */; | |
1700 | |
1701 /* Reset CBPCY predictors */ | |
2474 | 1702 memset(v->previous_line_cbpcy, 0, s->mb_stride<<2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1703 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1704 /* Select ttmb table depending on pq */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1705 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1706 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1707 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1708 |
2474 | 1709 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1710 { |
2462 | 1711 /* Init CBPCY for line */ |
1712 *((uint32_t*)previous_cbpcy) = 0x00000000; | |
1713 p_cbpcy = v->previous_line_cbpcy+4; | |
1714 | |
2474 | 1715 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1716 { |
2462 | 1717 /* Get CBPCY */ |
2474 | 1718 GET_CBPCY(ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS); |
2462 | 1719 |
2474 | 1720 s->ac_pred = get_bits(gb, 1); |
2462 | 1721 |
1722 /* TODO: Decode blocks from that mb wrt cbpcy */ | |
1723 | |
1724 /* Update for next block */ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1725 #if TRACE > 2 |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1726 av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i," |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1727 " cbpcy=%i%i%i%i\n", current_mb, |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1728 p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3], |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1729 previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3], |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1730 cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1731 #endif |
2462 | 1732 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); |
1733 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); | |
1734 current_mb++; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1735 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1736 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1737 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1738 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1739 |
2482 | 1740 /** |
1741 * @def GET_MQUANT | |
1742 * @brief Get macroblock-level quantizer scale | |
1743 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1744 #define GET_MQUANT() \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1745 if (v->dquantfrm) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1746 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1747 if (v->dqprofile == DQPROFILE_ALL_MBS) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1748 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1749 if (v->dqbilevel) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1750 { \ |
2474 | 1751 mquant = (get_bits(gb, 1)) ? v->pq : v->altpq; \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1752 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1753 else \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1754 { \ |
2474 | 1755 mqdiff = get_bits(gb, 3); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1756 if (mqdiff != 7) mquant = v->pq + mqdiff; \ |
2474 | 1757 else mquant = get_bits(gb, 5); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1758 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1759 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1760 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1761 |
2482 | 1762 /** |
1763 * @def GET_MVDATA(_dmv_x, _dmv_y) | |
1764 * @brief Get MV differentials | |
1765 * @see MVDATA decoding from 8.3.5.2, p(1)20 | |
1766 * @param dmv_x Horizontal differential for decoded MV | |
1767 * @param dmv_y Vertical differential for decoded MV | |
1768 */ | |
2462 | 1769 #define GET_MVDATA(_dmv_x, _dmv_y) \ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1770 index = 1 + get_vlc2(gb, vc9_mv_diff_vlc[s->mv_table_index].table,\ |
2462 | 1771 VC9_MV_DIFF_VLC_BITS, 2); \ |
1772 if (index > 36) \ | |
1773 { \ | |
1774 mb_has_coeffs = 1; \ | |
1775 index -= 37; \ | |
1776 } \ | |
1777 else mb_has_coeffs = 0; \ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1778 s->mb_intra = 0; \ |
2462 | 1779 if (!index) { _dmv_x = _dmv_y = 0; } \ |
1780 else if (index == 35) \ | |
1781 { \ | |
2474 | 1782 _dmv_x = get_bits(gb, k_x); \ |
1783 _dmv_y = get_bits(gb, k_y); \ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1784 s->mb_intra = 1; \ |
2462 | 1785 } \ |
1786 else \ | |
1787 { \ | |
1788 index1 = index%6; \ | |
1789 if (hpel_flag && index1 == 5) val = 1; \ | |
1790 else val = 0; \ | |
2474 | 1791 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1792 sign = 0 - (val&1); \ |
1793 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ | |
1794 \ | |
1795 index1 = index/6; \ | |
1796 if (hpel_flag && index1 == 5) val = 1; \ | |
1797 else val = 0; \ | |
2474 | 1798 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1799 sign = 0 - (val&1); \ |
1800 _dmv_y = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1801 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1802 |
2482 | 1803 /** Decode all MBs for an P frame in Simple/Main profile |
1804 * @see 8.1, p(1)15 | |
1805 * @todo TODO: Process the blocks | |
1806 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1807 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1808 static int decode_p_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1809 { |
2474 | 1810 MpegEncContext *s = &v->s; |
1811 GetBitContext *gb = &v->s.gb; | |
1812 int current_mb = 0, i; /* MB/Block Position info */ | |
2462 | 1813 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
1814 *p_cbpcy /* Pointer to skip some math */; | |
2474 | 1815 int hybrid_pred; /* Prediction types */ |
2462 | 1816 int mv_mode_bit = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1817 int mqdiff, mquant; /* MB quantization */ |
2462 | 1818 int ttmb; /* MB Transform type */ |
1819 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1820 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1821 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1822 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 1823 int dmv_x, dmv_y; /* Differential MV components */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1824 int k_x, k_y; /* Long MV fixed bitlength */ |
2462 | 1825 int hpel_flag; /* Some MB properties */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1826 int index, index1; /* LUT indices */ |
2462 | 1827 int val, sign; /* MVDATA temp values */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1828 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1829 /* Select ttmb table depending on pq */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1830 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1831 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1832 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1833 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1834 /* Select proper long MV range */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1835 switch (v->mvrange) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1836 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1837 case 1: k_x = 10; k_y = 9; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1838 case 2: k_x = 12; k_y = 10; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1839 case 3: k_x = 13; k_y = 11; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1840 default: /*case 0 too */ k_x = 9; k_y = 8; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1841 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1842 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1843 hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1844 k_x -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1845 k_y -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1846 |
2462 | 1847 /* Reset CBPCY predictors */ |
2474 | 1848 memset(v->previous_line_cbpcy, 0, s->mb_stride<<2); |
2462 | 1849 |
2474 | 1850 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1851 { |
2462 | 1852 /* Init CBPCY for line */ |
1853 *((uint32_t*)previous_cbpcy) = 0x00000000; | |
1854 p_cbpcy = v->previous_line_cbpcy+4; | |
1855 | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1856 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1857 { |
2462 | 1858 if (v->mv_type_mb_plane.is_raw) |
2474 | 1859 v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 1860 if (v->skip_mb_plane.is_raw) |
2474 | 1861 v->skip_mb_plane.data[current_mb] = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1862 if (!mv_mode_bit) /* 1MV mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1863 { |
2462 | 1864 if (!v->skip_mb_plane.data[current_mb]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1865 { |
2462 | 1866 GET_MVDATA(dmv_x, dmv_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1867 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1868 /* hybrid mv pred, 8.3.5.3.4 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1869 if (v->mv_mode == MV_PMODE_1MV || |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1870 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 1871 hybrid_pred = get_bits(gb, 1); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1872 if (s->mb_intra && !mb_has_coeffs) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1873 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1874 GET_MQUANT(); |
2474 | 1875 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1876 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1877 else if (mb_has_coeffs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1878 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1879 if (s->mb_intra) s->ac_pred = get_bits(gb, 1); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1880 predicted_cbpcy = get_vlc2(gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1881 cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2]; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1882 cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1883 cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3]; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1884 cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1885 cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0]; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1886 cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1887 cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1]; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1888 cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1889 //GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1890 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1891 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1892 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1893 if (!v->ttmbf) |
2474 | 1894 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 1895 VC9_TTMB_VLC_BITS, 12); |
1896 /* TODO: decode blocks from that mb wrt cbpcy */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1897 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1898 else //Skipped |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1899 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1900 /* hybrid mv pred, 8.3.5.3.4 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1901 if (v->mv_mode == MV_PMODE_1MV || |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1902 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 1903 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1904 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1905 } //1MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1906 else //4MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1907 { |
2462 | 1908 if (!v->skip_mb_plane.data[current_mb] /* unskipped MB */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1909 { |
2462 | 1910 /* Get CBPCY */ |
1911 GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1912 for (i=0; i<4; i++) //For all 4 Y blocks |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1913 { |
2462 | 1914 if (cbpcy[i] /* cbpcy set for this block */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1915 { |
2462 | 1916 GET_MVDATA(dmv_x, dmv_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1917 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1918 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 1919 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1920 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1921 if (s->mb_intra /* One of the 4 blocks is intra */ && |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1922 index /* non-zero pred for that block */) |
2474 | 1923 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1924 if (!v->ttmbf) |
2474 | 1925 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 1926 VC9_TTMB_VLC_BITS, 12); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1927 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1928 /* TODO: Process blocks wrt cbpcy */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1929 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1930 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1931 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1932 else //Skipped MB |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1933 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1934 for (i=0; i<4; i++) //All 4 Y blocks |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1935 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1936 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 1937 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1938 |
2462 | 1939 /* TODO: do something */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1940 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1941 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1942 } |
2462 | 1943 |
1944 /* Update for next block */ | |
1945 #if TRACE > 2 | |
2474 | 1946 av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i," |
2462 | 1947 " cbpcy=%i%i%i%i\n", current_mb, |
1948 p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3], | |
1949 previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3], | |
1950 cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]); | |
1951 #endif | |
1952 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); | |
1953 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); | |
1954 current_mb++; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1955 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1956 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1957 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1958 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1959 |
2482 | 1960 /** Decode all MBs for an P frame in Simple/Main profile |
1961 * @todo TODO: Process the blocks | |
1962 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1963 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1964 static int decode_b_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1965 { |
2474 | 1966 MpegEncContext *s = &v->s; |
1967 GetBitContext *gb = &v->s.gb; | |
1968 int current_mb = 0, i /* MB / B postion information */; | |
2462 | 1969 int b_mv_type = BMV_TYPE_BACKWARD; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1970 int mquant, mqdiff; /* MB quant stuff */ |
2462 | 1971 int ttmb; /* MacroBlock transform type */ |
1972 | |
1973 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, | |
1974 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1975 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 1976 int dmv1_x, dmv1_y, dmv2_x, dmv2_y; /* Differential MV components */ |
1977 int k_x, k_y; /* Long MV fixed bitlength */ | |
1978 int hpel_flag; /* Some MB properties */ | |
1979 int index, index1; /* LUT indices */ | |
1980 int val, sign; /* MVDATA temp values */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1981 |
2462 | 1982 /* Select proper long MV range */ |
1983 switch (v->mvrange) | |
1984 { | |
1985 case 1: k_x = 10; k_y = 9; break; | |
1986 case 2: k_x = 12; k_y = 10; break; | |
1987 case 3: k_x = 13; k_y = 11; break; | |
1988 default: /*case 0 too */ k_x = 9; k_y = 8; break; | |
1989 } | |
1990 hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL | |
1991 k_x -= hpel_flag; | |
1992 k_y -= hpel_flag; | |
1993 | |
1994 /* Select ttmb table depending on pq */ | |
1995 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; | |
1996 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; | |
1997 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; | |
1998 | |
2474 | 1999 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2000 { |
2474 | 2001 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2002 { |
2462 | 2003 if (v->direct_mb_plane.is_raw) |
2474 | 2004 v->direct_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 2005 if (v->skip_mb_plane.is_raw) |
2474 | 2006 v->skip_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 2007 |
2008 if (!v->direct_mb_plane.data[current_mb]) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2009 { |
2462 | 2010 if (v->skip_mb_plane.data[current_mb]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2011 { |
2474 | 2012 b_mv_type = decode012(gb); |
2462 | 2013 if (v->bfraction > 420 /*1/2*/ && |
2014 b_mv_type < 3) b_mv_type = 1-b_mv_type; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2015 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2016 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2017 { |
2462 | 2018 GET_MVDATA(dmv1_x, dmv1_y); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2019 if (!s->mb_intra /* b_mv1 tells not intra */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2020 { |
2474 | 2021 b_mv_type = decode012(gb); |
2462 | 2022 if (v->bfraction > 420 /*1/2*/ && |
2023 b_mv_type < 3) b_mv_type = 1-b_mv_type; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2024 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2025 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2026 } |
2462 | 2027 if (!v->skip_mb_plane.data[current_mb]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2028 { |
2462 | 2029 if (mb_has_coeffs /* BMV1 == "last" */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2030 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2031 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2032 if (s->mb_intra /* intra mb */) |
2474 | 2033 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2034 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2035 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2036 { |
2462 | 2037 /* if bmv1 tells MVs are interpolated */ |
2038 if (b_mv_type == BMV_TYPE_INTERPOLATED) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2039 { |
2462 | 2040 GET_MVDATA(dmv2_x, dmv2_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2041 } |
2462 | 2042 /* GET_MVDATA has reset some stuff */ |
2043 if (mb_has_coeffs /* b_mv2 == "last" */) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2044 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2045 if (s->mb_intra /* intra_mb */) |
2474 | 2046 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2047 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2048 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2049 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2050 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2051 //End1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2052 if (v->ttmbf) |
2474 | 2053 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 2054 VC9_TTMB_VLC_BITS, 12); |
2055 | |
2056 //End2 | |
2057 for (i=0; i<6; i++) | |
2058 { | |
2059 /* FIXME: process the block */ | |
2060 } | |
2061 | |
2062 current_mb++; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2063 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2064 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2065 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2066 } |
2482 | 2067 /** @} */ //End for group std_mb |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2068 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2069 #if HAS_ADVANCED_PROFILE |
2482 | 2070 /***********************************************************************/ |
2071 /** | |
2072 * @defgroup adv_mb VC9 Macroblock-level functions in Advanced Profile | |
2073 * @todo TODO: Integrate to MpegEncContext facilities | |
2074 * @todo TODO: Code P, B and BI | |
2075 * @{ | |
2076 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2077 static int advanced_decode_i_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2078 { |
2474 | 2079 MpegEncContext *s = &v->s; |
2080 GetBitContext *gb = &v->s.gb; | |
2081 int mqdiff, mquant, current_mb = 0, over_flags_mb = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2082 |
2474 | 2083 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2084 { |
2474 | 2085 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2086 { |
2474 | 2087 if (v->ac_pred_plane.is_raw) |
2088 s->ac_pred = get_bits(gb, 1); | |
2089 else | |
2090 s->ac_pred = v->ac_pred_plane.data[current_mb]; | |
2462 | 2091 if (v->condover == 3 && v->over_flags_plane.is_raw) |
2474 | 2092 over_flags_mb = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2093 GET_MQUANT(); |
2462 | 2094 |
2095 /* TODO: lots */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2096 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2097 current_mb++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2098 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2099 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2100 } |
2482 | 2101 /** @} */ //End for group adv_mb |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2102 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2103 |
2482 | 2104 /** Initialize a VC9/WMV3 decoder |
2105 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2106 * @todo TODO: Decypher remaining bits in extra_data | |
2107 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2108 static int vc9_decode_init(AVCodecContext *avctx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2109 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2110 VC9Context *v = avctx->priv_data; |
2474 | 2111 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2112 GetBitContext gb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2113 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2114 if (!avctx->extradata_size || !avctx->extradata) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2115 avctx->pix_fmt = PIX_FMT_YUV420P; |
2474 | 2116 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2117 |
2474 | 2118 if(ff_h263_decode_init(avctx) < 0) |
2119 return -1; | |
2120 if (vc9_init_common(v) < 0) return -1; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2121 |
2462 | 2122 avctx->coded_width = avctx->width; |
2123 avctx->coded_height = avctx->height; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2124 if (avctx->codec_id == CODEC_ID_WMV3) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2125 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2126 int count = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2127 |
2474 | 2128 // looks like WMV3 has a sequence header stored in the extradata |
2129 // advanced sequence header may be before the first frame | |
2130 // the last byte of the extradata is a version number, 1 for the | |
2131 // samples we can decode | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2132 |
2474 | 2133 init_get_bits(&gb, avctx->extradata, avctx->extradata_size); |
2134 | |
2135 decode_sequence_header(avctx, &gb); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2136 |
2474 | 2137 count = avctx->extradata_size*8 - get_bits_count(&gb); |
2138 if (count>0) | |
2139 { | |
2140 av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", | |
2141 count, get_bits(&gb, count)); | |
2142 } | |
2143 else | |
2144 { | |
2145 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); | |
2146 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2147 } |
2474 | 2148 avctx->has_b_frames= !!(avctx->max_b_frames); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2149 |
2474 | 2150 s->mb_width = (avctx->coded_width+15)>>4; |
2151 s->mb_height = (avctx->coded_height+15)>>4; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2152 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2153 /* Allocate mb bitplanes */ |
2474 | 2154 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2155 return -1; |
2474 | 2156 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2157 return -1; |
2474 | 2158 if (alloc_bitplane(&v->skip_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2159 return -1; |
2474 | 2160 if (alloc_bitplane(&v->direct_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2161 return -1; |
2162 | |
2163 /* For predictors */ | |
2474 | 2164 v->previous_line_cbpcy = (uint8_t *)av_malloc(s->mb_stride*4); |
2462 | 2165 if (!v->previous_line_cbpcy) return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2166 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2167 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2168 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2169 { |
2474 | 2170 if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2171 return -1; |
2474 | 2172 if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2173 return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2174 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2175 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2176 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2177 return 0; |
2474 | 2178 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2179 |
2482 | 2180 /** Decode a VC9/WMV3 frame |
2181 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2182 * @warning Initial try at using MpegEncContext stuff | |
2183 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2184 static int vc9_decode_frame(AVCodecContext *avctx, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2185 void *data, int *data_size, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2186 uint8_t *buf, int buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2187 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2188 VC9Context *v = avctx->priv_data; |
2474 | 2189 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2190 int ret = FRAME_SKIPED, len, start_code; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2191 AVFrame *pict = data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2192 uint8_t *tmp_buf; |
2474 | 2193 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2194 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2195 //buf_size = 0 -> last frame |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2196 if (!buf_size) return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2197 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2198 len = avpicture_get_size(avctx->pix_fmt, avctx->width, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2199 avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2200 tmp_buf = (uint8_t *)av_mallocz(len); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2201 avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2202 avctx->width, avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2203 |
2474 | 2204 if (avctx->codec_id == CODEC_ID_VC9) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2205 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2206 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2207 // search for IDU's |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2208 // FIXME |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2209 uint32_t scp = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2210 int scs = 0, i = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2211 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2212 while (i < buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2213 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2214 for (; i < buf_size && scp != 0x000001; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2215 scp = ((scp<<8)|buf[i])&0xffffff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2216 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2217 if (scp != 0x000001) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2218 break; // eof ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2219 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2220 scs = buf[i++]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2221 |
2474 | 2222 init_get_bits(gb, buf+i, (buf_size-i)*8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2223 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2224 switch(scs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2225 { |
2462 | 2226 case 0x0A: //Sequence End Code |
2227 return 0; | |
2228 case 0x0B: //Slice Start Code | |
2229 av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n"); | |
2230 return -1; | |
2231 case 0x0C: //Field start code | |
2232 av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n"); | |
2233 return -1; | |
2234 case 0x0D: //Frame start code | |
2235 break; | |
2236 case 0x0E: //Entry point Start Code | |
2237 if (v->profile <= MAIN_PROFILE) | |
2238 av_log(avctx, AV_LOG_ERROR, | |
2239 "Found an entry point in profile %i\n", v->profile); | |
2474 | 2240 advanced_entry_point_process(avctx, gb); |
2462 | 2241 break; |
2242 case 0x0F: //Sequence header Start Code | |
2474 | 2243 decode_sequence_header(avctx, gb); |
2462 | 2244 break; |
2245 default: | |
2246 av_log(avctx, AV_LOG_ERROR, | |
2247 "Unsupported IDU suffix %lX\n", scs); | |
2248 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2249 |
2474 | 2250 i += get_bits_count(gb)*8; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2251 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2252 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2253 av_abort(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2254 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2255 } |
2474 | 2256 else |
2257 init_get_bits(&v->s.gb, buf, buf_size*8); | |
2258 | |
2259 s->flags= avctx->flags; | |
2260 s->flags2= avctx->flags2; | |
2261 | |
2262 /* no supplementary picture */ | |
2263 if (buf_size == 0) { | |
2264 /* special case for last picture */ | |
2265 if (s->low_delay==0 && s->next_picture_ptr) { | |
2266 *pict= *(AVFrame*)s->next_picture_ptr; | |
2267 s->next_picture_ptr= NULL; | |
2268 | |
2269 *data_size = sizeof(AVFrame); | |
2270 } | |
2271 | |
2272 return 0; | |
2273 } | |
2274 | |
2275 //No IDU - we mimic ff_h263_decode_frame | |
2276 s->bitstream_buffer_size=0; | |
2277 | |
2278 if (!s->context_initialized) { | |
2279 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix | |
2280 return -1; | |
2281 } | |
2282 | |
2283 //we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there | |
2284 if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ | |
2285 s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)]; | |
2286 } | |
2287 #if HAS_ADVANCED_PROFILE | |
2288 if (v->profile > PROFILE_MAIN) | |
2289 ret= advanced_decode_picture_primary_header(v); | |
2290 else | |
2291 #endif | |
2292 ret= standard_decode_picture_primary_header(v); | |
2293 if (ret == FRAME_SKIPED) return buf_size; | |
2294 /* skip if the header was thrashed */ | |
2295 if (ret < 0){ | |
2296 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); | |
2297 return -1; | |
2298 } | |
2299 | |
2300 //No bug workaround yet, no DCT conformance | |
2301 | |
2302 //WMV9 does have resized images | |
2303 if (v->profile <= PROFILE_MAIN && v->multires){ | |
2304 //Parse context stuff in here, don't know how appliable it is | |
2305 } | |
2306 //Not sure about context initialization | |
2307 | |
2308 // for hurry_up==5 | |
2309 s->current_picture.pict_type= s->pict_type; | |
2310 s->current_picture.key_frame= s->pict_type == I_TYPE; | |
2311 | |
2312 /* skip b frames if we dont have reference frames */ | |
2313 if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) | |
2314 return buf_size; //FIXME simulating all buffer consumed | |
2315 /* skip b frames if we are in a hurry */ | |
2316 if(avctx->hurry_up && s->pict_type==B_TYPE) | |
2317 return buf_size; //FIXME simulating all buffer consumed | |
2318 /* skip everything if we are in a hurry>=5 */ | |
2319 if(avctx->hurry_up>=5) | |
2320 return buf_size; //FIXME simulating all buffer consumed | |
2321 | |
2322 if(s->next_p_frame_damaged){ | |
2323 if(s->pict_type==B_TYPE) | |
2324 return buf_size; //FIXME simulating all buffer consumed | |
2325 else | |
2326 s->next_p_frame_damaged=0; | |
2327 } | |
2328 | |
2329 if(MPV_frame_start(s, avctx) < 0) | |
2330 return -1; | |
2331 | |
2332 ff_er_frame_start(s); | |
2333 | |
2334 //wmv9 may or may not have skip bits | |
2335 #if HAS_ADVANCED_PROFILE | |
2336 if (v->profile > PROFILE_MAIN) | |
2337 ret= advanced_decode_picture_secondary_header(v); | |
2338 else | |
2339 #endif | |
2340 ret = standard_decode_picture_secondary_header(v); | |
2341 if (ret<0) return FRAME_SKIPED; //FIXME Non fatal for now | |
2342 | |
2343 //We consider the image coded in only one slice | |
2344 #if HAS_ADVANCED_PROFILE | |
2345 if (v->profile > PROFILE_MAIN) | |
2346 { | |
2347 switch(s->pict_type) | |
2348 { | |
2349 case I_TYPE: ret = advanced_decode_i_mbs(v); break; | |
2350 case P_TYPE: ret = decode_p_mbs(v); break; | |
2351 case B_TYPE: | |
2352 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2353 default: ret = FRAME_SKIPED; | |
2354 } | |
2355 if (ret == FRAME_SKIPED) return buf_size; //We ignore for now failures | |
2356 } | |
2357 else | |
2358 #endif | |
2359 { | |
2360 switch(s->pict_type) | |
2361 { | |
2362 case I_TYPE: ret = standard_decode_i_mbs(v); break; | |
2363 case P_TYPE: ret = decode_p_mbs(v); break; | |
2364 case B_TYPE: | |
2365 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2366 default: ret = FRAME_SKIPED; | |
2367 } | |
2368 if (ret == FRAME_SKIPED) return buf_size; | |
2369 } | |
2370 | |
2371 ff_er_frame_end(s); | |
2372 | |
2373 MPV_frame_end(s); | |
2374 | |
2375 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); | |
2376 assert(s->current_picture.pict_type == s->pict_type); | |
2377 if(s->pict_type==B_TYPE || s->low_delay){ | |
2378 *pict= *(AVFrame*)&s->current_picture; | |
2379 ff_print_debug_info(s, pict); | |
2380 } else { | |
2381 *pict= *(AVFrame*)&s->last_picture; | |
2382 if(pict) | |
2383 ff_print_debug_info(s, pict); | |
2384 } | |
2385 | |
2386 /* Return the Picture timestamp as the frame number */ | |
2387 /* we substract 1 because it is added on utils.c */ | |
2388 avctx->frame_number = s->picture_number - 1; | |
2389 | |
2390 /* dont output the last pic after seeking */ | |
2391 if(s->last_picture_ptr || s->low_delay) | |
2392 *data_size = sizeof(AVFrame); | |
2393 | |
2462 | 2394 av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n", |
2474 | 2395 get_bits_count(&s->gb), buf_size*8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2396 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2397 /* Fake consumption of all data */ |
2462 | 2398 *data_size = len; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2399 return buf_size; //Number of bytes consumed |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2400 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2401 |
2482 | 2402 /** Close a VC9/WMV3 decoder |
2403 * @warning Initial try at using MpegEncContext stuff | |
2404 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2405 static int vc9_decode_end(AVCodecContext *avctx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2406 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2407 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2408 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2409 #if HAS_ADVANCED_PROFILE |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2410 av_freep(&v->hrd_rate); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2411 av_freep(&v->hrd_buffer); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2412 #endif |
2474 | 2413 MPV_common_end(&v->s); |
2414 free_bitplane(&v->mv_type_mb_plane); | |
2415 free_bitplane(&v->skip_mb_plane); | |
2416 free_bitplane(&v->direct_mb_plane); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2417 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2418 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2419 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2420 AVCodec vc9_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2421 "vc9", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2422 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2423 CODEC_ID_VC9, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2424 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2425 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2426 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2427 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2428 vc9_decode_frame, |
2453 | 2429 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2430 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2431 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2432 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2433 AVCodec wmv3_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2434 "wmv3", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2435 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2436 CODEC_ID_WMV3, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2437 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2438 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2439 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2440 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2441 vc9_decode_frame, |
2453 | 2442 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2443 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2444 }; |