Mercurial > libavcodec.hg
annotate vc9.c @ 2482:5d28ea40fd98 libavcodec
Documentation patch by anonymous
author | michael |
---|---|
date | Tue, 01 Feb 2005 09:51:49 +0000 |
parents | 38dbec9a148d |
children | 4eb9d61cad4e |
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 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
76 #define QUANT_FRAME_IMPLICIT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
77 #define QUANT_FRAME_EXPLICIT 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
78 #define QUANT_NON_UNIFORM 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
79 #define QUANT_UNIFORM 3 |
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; | |
281 uint8_t pquantizer; | |
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; | |
302 uint8_t topleftx; | |
303 uint8_t toplefty; | |
304 uint8_t bottomrightx; | |
305 uint8_t bottomrighty; | |
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 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
338 return i; |
2462 | 339 #else |
340 unsigned int buf; | |
341 int log; | |
342 | |
343 OPEN_READER(re, gb); | |
344 UPDATE_CACHE(re, gb); | |
345 buf=GET_CACHE(re, gb); //Still not sure | |
346 if (stop) buf = ~buf; | |
347 | |
348 log= av_log2(-buf); //FIXME: -? | |
349 if (log < limit){ | |
350 LAST_SKIP_BITS(re, gb, log+1); | |
351 CLOSE_READER(re, gb); | |
352 return log; | |
353 } | |
354 | |
355 LAST_SKIP_BITS(re, gb, limit); | |
356 CLOSE_READER(re, gb); | |
357 return limit; | |
358 #endif | |
359 } | |
360 | |
2482 | 361 /** |
362 * Init VC-9 specific tables and VC9Context members | |
363 * @param v The VC9Context to initialize | |
364 * @return Status | |
365 */ | |
2474 | 366 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
|
367 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
368 static int done = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
369 int i; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
370 |
2462 | 371 /* Set the bit planes */ |
372 v->mv_type_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
373 v->direct_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
374 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
|
375 #if HAS_ADVANCED_PROFILE |
2462 | 376 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
|
377 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
|
378 #endif |
2462 | 379 |
380 /* VLC tables */ | |
2482 | 381 #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
|
382 # 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 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
|
392 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
393 # endif |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
394 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
395 if(!done) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
396 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
397 done = 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
398 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
|
399 vc9_bfraction_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
400 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
|
401 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
|
402 vc9_norm2_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
403 vc9_norm2_codes, 1, 1, 1); |
2482 | 404 #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
|
405 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
|
406 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
|
407 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
|
408 #endif |
2482 | 409 #if VLC_NORM6_METH0D == 2 |
410 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
|
411 &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
|
412 &vc9_norm6_first[0][0], 1, 1, 1); |
2482 | 413 INIT_VLC(&vc9_norm6_second_vlc, VC9_NORM6_SECOND_BITS, 22, |
414 &vc9_norm6_second[0][1], 1, 1, | |
415 &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
|
416 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
417 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
|
418 vc9_imode_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
419 vc9_imode_codes, 1, 1, 1); |
2462 | 420 for (i=0; i<3; i++) |
421 { | |
422 INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16, | |
423 vc9_ttmb_bits[i], 1, 1, | |
424 vc9_ttmb_codes[i], 2, 2, 1); | |
425 } | |
426 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
|
427 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 } |
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 |
2462 | 440 /* Other defaults */ |
441 v->pq = -1; | |
442 v->mvrange = 0; /* 7.1.1.18, p80 */ | |
443 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
444 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
445 } |
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 #if HAS_ADVANCED_PROFILE |
2482 | 448 /** |
449 * Decode sequence header's Hypothetic Reference Decoder data | |
450 * @see 6.2.1, p32 | |
451 * @param v The VC9Context to initialize | |
452 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
453 * @return Status | |
454 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
455 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
|
456 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
457 int i, num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
458 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
459 num = get_bits(gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
460 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
461 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
|
462 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
463 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
|
464 } |
2462 | 465 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
|
466 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
|
467 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
468 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
|
469 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
470 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
|
471 } |
2462 | 472 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
|
473 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
|
474 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
475 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
|
476 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
477 //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
|
478 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
|
479 //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
|
480 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
|
481 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
482 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
|
483 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
484 //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
|
485 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
|
486 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
|
487 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
488 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
|
489 "%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
|
490 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
491 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
492 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
|
493 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
|
494 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
495 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
|
496 "%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
|
497 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
498 } |
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 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
501 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
502 |
2482 | 503 /** |
504 * Decode sequence header for Advanced Profile | |
505 * @see Table 2, p18 | |
506 * @see 6.1.7, pp21-27 | |
507 * @param v The VC9Context to initialize | |
508 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
509 * @return Status | |
510 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
511 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
|
512 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
513 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
514 int nr, dr, aspect_ratio; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
515 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
516 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
|
517 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
|
518 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
|
519 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
520 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
|
521 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
|
522 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
|
523 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
|
524 if (v->reserved) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
525 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
526 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
|
527 v->reserved); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
528 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
529 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
530 if (v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
531 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
|
532 |
2462 | 533 /* 6.1.7, p21 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
534 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
|
535 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
536 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
|
537 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
|
538 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
|
539 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
540 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
|
541 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
|
542 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
543 |
2462 | 544 /* 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
|
545 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
|
546 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
547 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
|
548 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
|
549 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
550 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
|
551 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
|
552 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
553 else if (aspect_ratio == 0x0E) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
554 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
555 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
|
556 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
557 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
558 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
559 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
|
560 } |
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 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
564 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
565 avctx->coded_width = avctx->width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
566 avctx->coded_height = avctx->height; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
567 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
568 |
2462 | 569 /* 6.1.8, p23 */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
570 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
|
571 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
572 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
|
573 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
574 nr = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
575 dr = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
576 if (nr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
577 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
578 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
|
579 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
580 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
581 if (nr>5) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
582 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
583 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
|
584 "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
|
585 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
586 if (dr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
587 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
588 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
|
589 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
590 if (dr>2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
591 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
592 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
|
593 "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
|
594 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
595 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
|
596 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
|
597 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
598 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
599 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
600 nr = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
601 // 0.03125->2048Hz / 0.03125Hz |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
602 avctx->frame_rate = 1000000; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
603 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
|
604 } |
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 |
2462 | 607 /* 6.1.9, p25 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
608 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
|
609 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
610 //Chromacity coordinates of color primaries |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
611 //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
|
612 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
|
613 if (v->color_prim<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
614 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
615 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
|
616 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
617 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
618 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
|
619 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
620 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
|
621 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
622 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
623 } |
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 //Opto-electronic transfer characteristics |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
626 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
|
627 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
|
628 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
629 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
|
630 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
631 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
632 } |
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 //Matrix coefficient for primariev->YCbCr |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
635 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
|
636 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
|
637 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
|
638 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
639 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
|
640 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
641 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
642 } |
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 //Hypothetical reference decoder indicator flag |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
646 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
|
647 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
648 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
649 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
|
650 } |
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 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
|
653 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
654 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
655 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
656 |
2482 | 657 /** |
658 * Decode Simple/Main Profiles sequence header | |
659 * @see Figure 7-8, p16-17 | |
660 * @param avctx Codec context | |
661 * @param gb GetBit context initialized from Codec context extra_data | |
662 * @return Status | |
663 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
664 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
|
665 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
666 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
667 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
668 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
|
669 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
|
670 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
671 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
672 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
673 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
674 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
|
675 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
|
676 if (v->chromaformat != 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
677 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
678 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
|
679 "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
|
680 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
681 } |
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 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
684 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
685 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
686 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
|
687 if (v->res_sm) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
688 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
689 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
|
690 "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
|
691 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
692 } |
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 // (fps-2)/4 (->30) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
696 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
|
697 // (bitrate-32kbps)/64kbps |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
698 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
|
699 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
|
700 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
701 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
702 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
703 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
704 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
705 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
|
706 if (v->res_x8) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
707 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
708 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
|
709 "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
|
710 //return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
711 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
712 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
|
713 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
|
714 if (!v->res_fasttx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
715 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
716 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
|
717 "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
|
718 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
719 } |
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 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
|
723 if (!v->profile && !v->fastuvmc) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
724 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
725 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
|
726 "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
|
727 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
728 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
729 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
|
730 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
|
731 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
732 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
|
733 "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
|
734 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
735 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
736 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
|
737 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
|
738 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
739 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
740 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
741 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
742 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
743 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
|
744 if (v->res_transtab) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
745 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
746 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
|
747 "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
|
748 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
749 } |
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 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
|
753 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
754 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
755 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
756 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
757 { |
2474 | 758 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
|
759 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
|
760 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
761 |
2474 | 762 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
|
763 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
|
764 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
765 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
766 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
767 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
768 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
769 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
|
770 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
|
771 if (!v->res_rtm_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
772 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
773 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
|
774 "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
|
775 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
776 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
777 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
778 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
|
779 "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
|
780 "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
|
781 "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
|
782 "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
|
783 v->profile, v->frmrtq_postproc, v->bitrtq_postproc, |
2482 | 784 v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, |
2474 | 785 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
|
786 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
|
787 ); |
2462 | 788 return 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
789 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
790 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
791 #if HAS_ADVANCED_PROFILE |
2462 | 792 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
|
793 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
794 } |
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 #if HAS_ADVANCED_PROFILE |
2482 | 798 /** Entry point decoding (Advanced Profile) |
799 * @param avctx Codec context | |
800 * @param gb GetBit context initialized from avctx->extra_data | |
801 * @return Status | |
802 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
803 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
|
804 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
805 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
806 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
|
807 if (v->profile != PROFILE_ADVANCED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
808 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
809 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
|
810 "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
|
811 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
|
812 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
813 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
814 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
815 //Update buffer fullness |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
816 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
|
817 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
|
818 skip_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
819 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
820 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
|
821 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
822 //RANGE_MAPY |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
823 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
|
824 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
825 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
826 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
|
827 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
828 //RANGE_MAPUV |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
829 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
|
830 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
831 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
832 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
833 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
834 //NUMPANSCANWIN |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
835 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
|
836 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
|
837 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
838 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
839 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
840 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
841 |
2482 | 842 /***********************************************************************/ |
843 /** | |
844 * @defgroup bitplane VC9 Bitplane decoding | |
845 * @see 8.7, p56 | |
846 * @{ | |
847 */ | |
848 | |
849 /** @addtogroup bitplane | |
850 * Imode types | |
851 * @{ | |
852 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
853 #define IMODE_RAW 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
854 #define IMODE_NORM2 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
855 #define IMODE_DIFF2 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
856 #define IMODE_NORM6 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
857 #define IMODE_DIFF6 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
858 #define IMODE_ROWSKIP 5 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
859 #define IMODE_COLSKIP 6 |
2482 | 860 /** @} */ //imode defines |
861 | |
862 /** Allocate the buffer from a bitplane, given its dimensions | |
863 * @param bp Bitplane which buffer is to allocate | |
864 * @param[in] width Width of the buffer | |
865 * @param[in] height Height of the buffer | |
866 * @return Status | |
867 * @todo TODO: Take into account stride | |
868 * @todo TODO: Allow use of external buffers ? | |
869 */ | |
2462 | 870 int alloc_bitplane(BitPlane *bp, int width, int height) |
871 { | |
872 if (!bp || bp->width<0 || bp->height<0) return -1; | |
873 bp->data = (uint8_t*)av_malloc(width*height); | |
874 if (!bp->data) return -1; | |
2482 | 875 bp->width = bp->stride = width; |
2462 | 876 bp->height = height; |
877 return 0; | |
878 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
879 |
2482 | 880 /** Free the bitplane's buffer |
881 * @param bp Bitplane which buffer is to free | |
882 */ | |
2474 | 883 void free_bitplane(BitPlane *bp) |
884 { | |
885 bp->width = bp->stride = bp->height = 0; | |
886 if (bp->data) av_freep(&bp->data); | |
887 } | |
888 | |
2482 | 889 /** Decode rows by checking if they are skiped |
890 * @param plane Buffer to store decoded bits | |
891 * @param[in] width Width of this buffer | |
892 * @param[in] height Height of this buffer | |
893 * @param[in] stride of this buffer | |
894 */ | |
2459 | 895 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ |
896 int x, y; | |
2474 | 897 GetBitContext *gb = &v->s.gb; |
2459 | 898 |
899 for (y=0; y<height; y++){ | |
2474 | 900 if (!get_bits(gb, 1)) //rowskip |
2459 | 901 memset(plane, 0, width); |
902 else | |
903 for (x=0; x<width; x++) | |
2474 | 904 plane[x] = get_bits(gb, 1); |
2459 | 905 plane += stride; |
906 } | |
907 } | |
908 | |
2482 | 909 /** Decode columns by checking if they are skiped |
910 * @param plane Buffer to store decoded bits | |
911 * @param[in] width Width of this buffer | |
912 * @param[in] height Height of this buffer | |
913 * @param[in] stride of this buffer | |
914 * @fixme FIXME: Optimize | |
915 */ | |
2459 | 916 static void decode_colskip(uint8_t* plane, int width, int height, int stride, VC9Context *v){ |
917 int x, y; | |
2474 | 918 GetBitContext *gb = &v->s.gb; |
2459 | 919 |
920 for (x=0; x<width; x++){ | |
2474 | 921 if (!get_bits(gb, 1)) //colskip |
2459 | 922 for (y=0; y<height; y++) |
923 plane[y*stride] = 0; | |
924 else | |
925 for (y=0; y<height; y++) | |
2474 | 926 plane[y*stride] = get_bits(gb, 1); |
2459 | 927 plane ++; |
928 } | |
929 } | |
930 | |
2482 | 931 /** Decode a bitplane's bits |
932 * @param bp Bitplane where to store the decode bits | |
933 * @param v VC9 context for bit reading and logging | |
934 * @return Status | |
935 * @fixme FIXME: Optimize | |
936 * @todo TODO: Decide if a struct is needed | |
937 */ | |
2462 | 938 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
|
939 { |
2474 | 940 GetBitContext *gb = &v->s.gb; |
941 | |
2462 | 942 int imode, x, y, code, use_vertical_tile, tile_w, tile_h; |
943 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
|
944 |
2474 | 945 invert = get_bits(gb, 1); |
946 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
|
947 |
2462 | 948 bp->is_raw = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
949 switch (imode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
950 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
951 case IMODE_RAW: |
2462 | 952 //Data is actually read in the MB layer (same for all tests == "raw") |
953 bp->is_raw = 1; //invert ignored | |
954 return invert; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
955 case IMODE_DIFF2: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
956 case IMODE_NORM2: |
2474 | 957 if ((bp->height*bp->width) & 1) *(++planep) = get_bits(gb, 1); |
2462 | 958 for(x=0; x<(bp->height*bp->width)>>1; x++){ |
2474 | 959 code = get_vlc2(gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); |
2459 | 960 *(++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
|
961 *(++planep) = (code>>1)&1; //msb => right |
2459 | 962 //FIXME width->stride |
963 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
964 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
965 case IMODE_DIFF6: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
966 case IMODE_NORM6: |
2462 | 967 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
|
968 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
|
969 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
|
970 |
2462 | 971 for(y= bp->height%tile_h; y< bp->height; y+=tile_h){ |
972 for(x= bp->width%tile_w; x< bp->width; x+=tile_w){ | |
2482 | 973 #if VLC_NORM6_METH0D == 1 |
2474 | 974 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
|
975 if(code<0){ |
2482 | 976 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
|
977 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
|
978 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
979 #endif |
2482 | 980 #if VLC_NORM6_METH0D == 2 //Failure |
981 code = get_vlc2(gb, vc9_norm6_first_vlc.table, VC9_NORM6_FIRST_BITS, 2); | |
982 if (code == 22) | |
983 { | |
984 code = vc9_norm6_flc_val[get_bits(gb, 5)]; | |
985 } | |
986 else if (code == 23) | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
987 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
988 # if TRACE |
2482 | 989 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
|
990 assert(code>-1 && code<22); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
991 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
|
992 # else |
2482 | 993 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
|
994 # endif |
2482 | 995 } |
996 #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
|
997 //FIXME following is a pure guess and probably wrong |
2462 | 998 //FIXME A bitplane (0 | !0), so could the shifts be avoided ? |
999 planep[x + 0*bp->stride]= (code>>0)&1; | |
1000 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
|
1001 //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
|
1002 if(use_vertical_tile){ |
2462 | 1003 planep[x + 0 + 1*bp->stride]= (code>>2)&1; |
1004 planep[x + 1 + 1*bp->stride]= (code>>3)&1; | |
1005 planep[x + 0 + 2*bp->stride]= (code>>4)&1; | |
1006 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
|
1007 }else{ |
2462 | 1008 planep[x + 2 + 0*bp->stride]= (code>>2)&1; |
1009 planep[x + 0 + 1*bp->stride]= (code>>3)&1; | |
1010 planep[x + 1 + 1*bp->stride]= (code>>4)&1; | |
1011 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
|
1012 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1013 } |
2459 | 1014 } |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1015 |
2462 | 1016 x= bp->width % tile_w; |
1017 decode_colskip(bp->data , x, bp->height , bp->stride, v); | |
1018 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
|
1019 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1020 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1021 case IMODE_ROWSKIP: |
2462 | 1022 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
|
1023 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1024 case IMODE_COLSKIP: //Teh ugly |
2462 | 1025 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
|
1026 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1027 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1028 } |
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 /* Applying diff operator */ |
2459 | 1031 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
|
1032 { |
2462 | 1033 planep = bp->data; |
2459 | 1034 planep[0] ^= invert; |
2462 | 1035 for (x=1; x<bp->width; x++) |
2459 | 1036 planep[x] ^= planep[x-1]; |
2462 | 1037 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
|
1038 { |
2462 | 1039 planep += bp->stride; |
1040 planep[0] ^= planep[-bp->stride]; | |
1041 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
|
1042 { |
2462 | 1043 if (planep[x-1] != planep[x-bp->stride]) planep[x] ^= invert; |
1044 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
|
1045 } |
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 else if (invert) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1049 { |
2462 | 1050 planep = bp->data; |
1051 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
|
1052 } |
2462 | 1053 return (imode<<1) + invert; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1054 } |
2482 | 1055 /** @} */ //Bitplane group |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1056 |
2482 | 1057 /***********************************************************************/ |
1058 /** VOP Dquant decoding | |
1059 * @param v VC9 Context | |
1060 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1061 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
|
1062 { |
2474 | 1063 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
|
1064 int pqdiff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1065 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1066 //variable size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1067 if (v->dquant == 2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1068 { |
2474 | 1069 pqdiff = get_bits(gb, 3); |
1070 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
|
1071 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
|
1072 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1073 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1074 { |
2474 | 1075 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
|
1076 if ( v->dquantfrm ) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1077 { |
2474 | 1078 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
|
1079 switch (v->dqprofile) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1080 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1081 case DQPROFILE_SINGLE_EDGE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1082 case DQPROFILE_DOUBLE_EDGES: |
2474 | 1083 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
|
1084 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1085 case DQPROFILE_ALL_MBS: |
2474 | 1086 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
|
1087 default: break; //Forbidden ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1088 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1089 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
|
1090 { |
2474 | 1091 pqdiff = get_bits(gb, 3); |
1092 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
|
1093 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
|
1094 } |
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 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1098 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1099 |
2482 | 1100 /***********************************************************************/ |
1101 /** | |
1102 * @defgroup all_frame_hdr All VC9 profiles frame header | |
1103 * @brief Part of the frame header decoding from all profiles | |
1104 * @warning Only pro/epilog differs between Simple/Main and Advanced => check caller | |
1105 * @{ | |
1106 */ | |
1107 /** B and BI frame header decoding, primary part | |
1108 * @see Tables 11+12, p62-65 | |
1109 * @param v VC9 context | |
1110 * @return Status | |
1111 * @warning Also handles BI frames | |
1112 */ | |
2474 | 1113 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
|
1114 { |
2474 | 1115 GetBitContext *gb = &v->s.gb; |
1116 int pqindex, status; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1117 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1118 /* 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
|
1119 if (v->profile == PROFILE_SIMPLE) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1120 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1121 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
|
1122 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1123 } |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1151 /* Read the MV type/mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1152 if (v->extended_mv == 1) |
2474 | 1153 v->mvrange = get_prefix(gb, 0, 3); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1154 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
|
1155 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1156 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
|
1157 if (v->pq < 13) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1158 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1159 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1160 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1161 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
|
1162 if (v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1163 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
|
1164 "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
|
1165 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1166 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1167 else |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1168 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1169 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1170 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1171 if (get_bits(gb, 1)) |
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, |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1173 "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
|
1174 } |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1175 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
|
1176 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1177 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1178 |
2474 | 1179 return 0; |
1180 } | |
1181 | |
2482 | 1182 /** B and BI frame header decoding, secondary part |
1183 * @see Tables 11+12, p62-65 | |
1184 * @param v VC9 context | |
1185 * @return Status | |
1186 * @warning Also handles BI frames | |
1187 * @warning To call once all MB arrays are allocated | |
1188 */ | |
2474 | 1189 static int decode_b_picture_secondary_header(VC9Context *v) |
1190 { | |
1191 GetBitContext *gb = &v->s.gb; | |
1192 int status; | |
1193 | |
1194 bitplane_decoding(&v->skip_mb_plane, v); | |
1195 if (status < 0) return -1; | |
1196 #if TRACE | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1197 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
|
1198 { |
2462 | 1199 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1200 if (status < 0) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1201 return -1; |
2462 | 1202 #if TRACE |
2474 | 1203 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1204 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1205 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1206 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1207 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1208 //bitplane |
2462 | 1209 status = bitplane_decoding(&v->direct_mb_plane, v); |
1210 if (status < 0) return -1; | |
1211 #if TRACE | |
2474 | 1212 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct plane encoding: " |
2462 | 1213 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1214 #endif | |
1215 | |
2474 | 1216 av_log(v->s.avctx, AV_LOG_DEBUG, "Skip MB plane encoding: " |
2462 | 1217 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1218 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1219 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1220 /* 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
|
1221 v->s.mv_table_index = get_bits(gb, 2); //but using vc9_ tables |
2474 | 1222 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
|
1223 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1224 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1225 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1226 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1227 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1228 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1229 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1230 { |
2474 | 1231 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
|
1232 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1233 { |
2474 | 1234 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
|
1235 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
|
1236 (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
|
1237 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1238 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1239 /* 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
|
1240 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1241 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1242 |
2482 | 1243 /** I frame header decoding, primary part |
1244 * @see Tables 5+7, p53-54 and 55-57 | |
1245 * @param v VC9 context | |
1246 * @return Status | |
1247 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1248 static int decode_i_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1249 { |
2474 | 1250 GetBitContext *gb = &v->s.gb; |
1251 int pqindex, status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1252 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1253 /* 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
|
1254 //BF = Buffer Fullness |
2474 | 1255 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
|
1256 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1257 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
|
1258 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1259 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1260 /* Quantizer stuff */ |
2474 | 1261 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
|
1262 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
|
1263 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
|
1264 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1265 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1266 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
|
1267 } |
2474 | 1268 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
|
1269 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1270 v->pquantizer = get_bits(gb, 1); |
1271 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
|
1272 v->pq, v->halfpq); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1273 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1274 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1275 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1276 { |
2474 | 1277 if (v->extended_mv) v->mvrange = get_prefix(gb, 0, 3); |
1278 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
|
1279 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1280 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1281 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1282 { |
2474 | 1283 v->s.ac_pred = get_bits(gb, 1); |
1284 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
|
1285 /* 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
|
1286 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
|
1287 { |
2474 | 1288 v->condover = get_bits(gb, 1); |
2462 | 1289 if (v->condover) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1290 { |
2474 | 1291 v->condover = 2+get_bits(gb, 1); |
2462 | 1292 if (v->condover == 3) |
1293 { | |
1294 status = bitplane_decoding(&v->over_flags_plane, v); | |
1295 if (status < 0) return -1; | |
1296 #if TRACE | |
2474 | 1297 av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: " |
2462 | 1298 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1299 #endif | |
1300 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1301 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1302 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1303 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1304 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1305 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1306 /* 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
|
1307 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1308 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1309 |
2482 | 1310 /** P frame header decoding, primary part |
1311 * @see Tables 5+7, p53-54 and 55-57 | |
1312 * @param v VC9 context | |
1313 * @return Status | |
1314 */ | |
2474 | 1315 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
|
1316 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1317 /* INTERFRM, FRMCNT, RANGEREDFRM read in caller */ |
2474 | 1318 GetBitContext *gb = &v->s.gb; |
2462 | 1319 int lowquant, pqindex, status = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1320 |
2474 | 1321 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
|
1322 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
|
1323 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
|
1324 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1325 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1326 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
|
1327 } |
2474 | 1328 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
|
1329 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1330 v->pquantizer = get_bits(gb, 1); |
1331 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
|
1332 v->pq, v->halfpq); |
2474 | 1333 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
|
1334 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1335 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1336 { |
2474 | 1337 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
|
1338 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1339 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1340 #endif |
2474 | 1341 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
|
1342 lowquant = (v->pquantizer>12) ? 0 : 1; |
2474 | 1343 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
|
1344 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
|
1345 { |
2474 | 1346 v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(gb, 1, 3)]; |
1347 v->lumscale = get_bits(gb, 6); | |
1348 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
|
1349 } |
2474 | 1350 return 0; |
1351 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1352 |
2482 | 1353 /** P frame header decoding, secondary part |
1354 * @see Tables 5+7, p53-54 and 55-57 | |
1355 * @param v VC9 context | |
1356 * @warning To call once all MB arrays are allocated | |
1357 * @return Status | |
1358 */ | |
2474 | 1359 static int decode_p_picture_secondary_header(VC9Context *v) |
1360 { | |
1361 GetBitContext *gb = &v->s.gb; | |
1362 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1363 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
|
1364 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
|
1365 || 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
|
1366 { |
2462 | 1367 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1368 if (status < 0) return -1; | |
1369 #if TRACE | |
2474 | 1370 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1371 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1372 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1373 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1374 |
2462 | 1375 status = bitplane_decoding(&v->skip_mb_plane, v); |
1376 if (status < 0) return -1; | |
1377 #if TRACE | |
2474 | 1378 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " |
2462 | 1379 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1380 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1381 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1382 /* 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
|
1383 v->s.mv_table_index =get_bits(gb, 2); //but using vc9_ tables |
2474 | 1384 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
|
1385 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1386 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1387 { |
2474 | 1388 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
|
1389 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1390 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1391 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1392 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
|
1393 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1394 { |
2474 | 1395 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
|
1396 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1397 { |
2474 | 1398 v->ttfrm = get_bits(gb, 2); |
1399 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
|
1400 (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
|
1401 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1402 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1403 /* 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
|
1404 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1405 } |
2482 | 1406 /** @} */ //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
|
1407 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1408 |
2482 | 1409 /***********************************************************************/ |
1410 /** | |
1411 * @defgroup std_frame_hdr VC9 Simple/Main Profiles header decoding | |
1412 * @brief Part of the frame header decoding belonging to Simple/Main Profiles | |
1413 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1414 * check caller | |
1415 * @{ | |
1416 */ | |
1417 | |
1418 /** Frame header decoding, first part, in Simple and Main profiles | |
1419 * @see Tables 5+7, p53-54 and 55-57 | |
1420 * @param v VC9 context | |
1421 * @return Status | |
1422 */ | |
2474 | 1423 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
|
1424 { |
2474 | 1425 GetBitContext *gb = &v->s.gb; |
1426 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1427 |
2474 | 1428 if (v->finterpflag) v->interpfrm = get_bits(gb, 1); |
1429 skip_bits(gb, 2); //framecnt unused | |
1430 if (v->rangered) v->rangeredfrm = get_bits(gb, 1); | |
1431 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
|
1432 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
|
1433 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1434 if (!v->s.pict_type) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1435 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1436 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
|
1437 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
|
1438 } |
2474 | 1439 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
|
1440 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1441 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
|
1442 |
2474 | 1443 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
|
1444 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1445 case I_TYPE: status = decode_i_picture_header(v); break; |
2474 | 1446 case P_TYPE: status = decode_p_picture_primary_header(v); break; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1447 case BI_TYPE: |
2474 | 1448 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
|
1449 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1450 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1451 if (status == FRAME_SKIPED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1452 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1453 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
|
1454 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1455 } |
2474 | 1456 return 0; |
1457 } | |
1458 | |
2482 | 1459 /** Frame header decoding, secondary part |
1460 * @param v VC9 context | |
1461 * @warning To call once all MB arrays are allocated | |
1462 * @return Status | |
1463 */ | |
2474 | 1464 static int standard_decode_picture_secondary_header(VC9Context *v) |
1465 { | |
1466 GetBitContext *gb = &v->s.gb; | |
1467 int status = 0, index; | |
1468 | |
1469 switch (v->s.pict_type) | |
1470 { | |
1471 case P_TYPE: status = decode_p_picture_secondary_header(v); break; | |
1472 case B_TYPE: status = decode_b_picture_secondary_header(v); break; | |
1473 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1474 |
2462 | 1475 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1476 v->ac_table_level = decode012(gb); |
2474 | 1477 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
|
1478 { |
2482 | 1479 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
|
1480 } |
2462 | 1481 /* DC Syntax */ |
2474 | 1482 index = decode012(gb); |
1483 v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index]; | |
1484 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
|
1485 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1486 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1487 } |
2482 | 1488 /** @} */ //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
|
1489 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1490 #if HAS_ADVANCED_PROFILE |
2482 | 1491 /***********************************************************************/ |
1492 /** | |
1493 * @defgroup adv_frame_hdr VC9 Advanced Profile header decoding | |
1494 * @brief Part of the frame header decoding belonging to Advanced Profiles | |
1495 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1496 * check caller | |
1497 * @{ | |
1498 */ | |
1499 /** Frame header decoding, primary part | |
1500 * @param v VC9 context | |
1501 * @return Status | |
1502 */ | |
2474 | 1503 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
|
1504 { |
2474 | 1505 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
|
1506 static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE }; |
2474 | 1507 int type, i; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1508 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1509 if (v->interlace) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1510 { |
2474 | 1511 v->fcm = get_bits(gb, 1); |
1512 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
|
1513 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1514 |
2474 | 1515 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
|
1516 if (type > 4 || type < 0) return FRAME_SKIPED; |
2474 | 1517 v->s.pict_type = type_table[type]; |
1518 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
|
1519 |
2474 | 1520 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
|
1521 if (v->broadcast) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1522 { |
2474 | 1523 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
|
1524 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1525 { |
2474 | 1526 v->tff = get_bits(gb, 1); |
1527 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
|
1528 } |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1531 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1532 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1533 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1534 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
|
1535 { |
2474 | 1536 v->topleftx[i] = get_bits(gb, 16); |
1537 v->toplefty[i] = get_bits(gb, 16); | |
1538 v->bottomrightx[i] = get_bits(gb, 16); | |
1539 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
|
1540 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1541 #else |
2474 | 1542 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
|
1543 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1544 } |
2474 | 1545 v->s.no_rounding = !get_bits(gb, 1); |
1546 v->uvsamp = get_bits(gb, 1); | |
1547 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
|
1548 |
2474 | 1549 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
|
1550 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1551 case I_TYPE: if (decode_i_picture_header(v) < 0) return -1; |
2474 | 1552 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
|
1553 case BI_TYPE: |
2474 | 1554 case B_TYPE: if (decode_b_picture_primary_header(v) < 0) return FRAME_SKIPED; |
1555 default: break; | |
1556 } | |
1557 return 0; | |
1558 } | |
1559 | |
2482 | 1560 /** Frame header decoding, secondary part |
1561 * @param v VC9 context | |
1562 * @return Status | |
1563 */ | |
2474 | 1564 static int advanced_decode_picture_secondary_header(VC9Context *v) |
1565 { | |
1566 GetBitContext *gb = &v->s.gb; | |
1567 int index; | |
1568 | |
1569 switch(v->s.pict_type) | |
1570 { | |
1571 case P_TYPE: if (decode_p_picture_secondary_header(v) < 0) return -1; | |
1572 case B_TYPE: if (decode_b_picture_secondary_header(v) < 0) return FRAME_SKIPED; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1573 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1574 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1575 |
2462 | 1576 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1577 v->ac_table_level = decode012(gb); |
2474 | 1578 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
|
1579 { |
2482 | 1580 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
|
1581 } |
2462 | 1582 /* DC Syntax */ |
2474 | 1583 index = decode012(gb); |
1584 v->luma_dc_vlc = &ff_msmp4_dc_luma_vlc[index]; | |
1585 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
|
1586 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1587 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1588 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1589 #endif |
2482 | 1590 /** @} */ //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
|
1591 |
2482 | 1592 /***********************************************************************/ |
1593 /** | |
1594 * @defgroup block VC9 Block-level functions | |
1595 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 | |
1596 * @todo TODO: Integrate to MpegEncContext facilities | |
1597 * @{ | |
1598 */ | |
1599 /** Decode a luma intra block | |
1600 * @warning Will be removed, due to necessary integration | |
1601 * @see coeff scaling for Adv Profile: 8.1.1.15, p(1)13, | |
1602 * @param v VC9 context | |
1603 * @param mquant Macroblock quantizer scale | |
1604 * @return Status | |
1605 * @todo TODO: Implement Coeff scaling for Advanced Profile | |
1606 */ | |
2462 | 1607 int decode_luma_intra_block(VC9Context *v, int mquant) |
1608 { | |
2474 | 1609 GetBitContext *gb = &v->s.gb; |
2462 | 1610 int dcdiff; |
1611 | |
2474 | 1612 dcdiff = get_vlc2(gb, v->luma_dc_vlc->table, |
1613 DC_VLC_BITS, 2); | |
2462 | 1614 if (dcdiff) |
1615 { | |
1616 if (dcdiff == 119 /* ESC index value */) | |
1617 { | |
1618 /* TODO: Optimize */ | |
2474 | 1619 if (mquant == 1) dcdiff = get_bits(gb, 10); |
1620 else if (mquant == 2) dcdiff = get_bits(gb, 9); | |
1621 else dcdiff = get_bits(gb, 8); | |
2462 | 1622 } |
1623 else | |
1624 { | |
1625 if (mquant == 1) | |
2474 | 1626 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
2462 | 1627 else if (mquant == 2) |
2474 | 1628 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; |
2462 | 1629 } |
2474 | 1630 if (get_bits(gb, 1)) |
2462 | 1631 dcdiff = -dcdiff; |
1632 } | |
1633 /* FIXME: 8.1.1.15, p(1)13, coeff scaling for Adv Profile */ | |
1634 | |
1635 return 0; | |
1636 } | |
2482 | 1637 /** @} */ //End for group block |
2462 | 1638 |
2482 | 1639 /***********************************************************************/ |
1640 /** | |
1641 * @defgroup std_mb VC9 Macroblock-level functions in Simple/Main Profiles | |
1642 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 | |
1643 * @todo TODO: Integrate to MpegEncContext facilities | |
1644 * @{ | |
1645 */ | |
1646 /** | |
1647 * @def GET_CBPCY(table, bits) | |
1648 * @brief Get the Coded Block Pattern for luma and chroma | |
1649 * @param table VLC table to use (get_vlc2 second parameter) | |
1650 * @param bits Average bitlength (third parameter to get_vlc2) | |
1651 * @see 8.1.1.5, p(1)02-(1)03 | |
1652 */ | |
2462 | 1653 #define GET_CBPCY(table, bits) \ |
2474 | 1654 predicted_cbpcy = get_vlc2(gb, table, bits, 2); \ |
2462 | 1655 cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) \ |
1656 ? previous_cbpcy[1] : p_cbpcy[+2]; \ | |
1657 cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01); \ | |
1658 cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3]; \ | |
1659 cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01); \ | |
1660 cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) \ | |
1661 ? previous_cbpcy[3] : cbpcy[0]; \ | |
1662 cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01); \ | |
1663 cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1]; \ | |
1664 cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01); | |
1665 | |
2482 | 1666 /** Decode all MBs for an I frame in Simple/Main profile |
1667 * @see 8.1, p100 | |
1668 * @todo TODO: Process the blocks | |
1669 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1670 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1671 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
|
1672 { |
2474 | 1673 GetBitContext *gb = &v->s.gb; |
1674 MpegEncContext *s = &v->s; | |
1675 int current_mb = 0; /* MB/Block Position info */ | |
2462 | 1676 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
1677 *p_cbpcy /* Pointer to skip some math */; | |
1678 | |
1679 /* Reset CBPCY predictors */ | |
2474 | 1680 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
|
1681 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1682 /* 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
|
1683 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
|
1684 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
|
1685 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
|
1686 |
2474 | 1687 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
|
1688 { |
2462 | 1689 /* Init CBPCY for line */ |
1690 *((uint32_t*)previous_cbpcy) = 0x00000000; | |
1691 p_cbpcy = v->previous_line_cbpcy+4; | |
1692 | |
2474 | 1693 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
|
1694 { |
2462 | 1695 /* Get CBPCY */ |
2474 | 1696 GET_CBPCY(ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS); |
2462 | 1697 |
2474 | 1698 s->ac_pred = get_bits(gb, 1); |
2462 | 1699 |
1700 /* TODO: Decode blocks from that mb wrt cbpcy */ | |
1701 | |
1702 /* Update for next block */ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1703 #if TRACE > 2 |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1704 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
|
1705 " 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
|
1706 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
|
1707 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
|
1708 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
|
1709 #endif |
2462 | 1710 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); |
1711 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); | |
1712 current_mb++; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1713 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1714 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1715 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1716 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1717 |
2482 | 1718 /** |
1719 * @def GET_MQUANT | |
1720 * @brief Get macroblock-level quantizer scale | |
1721 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1722 #define GET_MQUANT() \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1723 if (v->dquantfrm) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1724 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1725 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
|
1726 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1727 if (v->dqbilevel) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1728 { \ |
2474 | 1729 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
|
1730 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1731 else \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1732 { \ |
2474 | 1733 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
|
1734 if (mqdiff != 7) mquant = v->pq + mqdiff; \ |
2474 | 1735 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
|
1736 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1737 } \ |
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_MVDATA(_dmv_x, _dmv_y) | |
1742 * @brief Get MV differentials | |
1743 * @see MVDATA decoding from 8.3.5.2, p(1)20 | |
1744 * @param dmv_x Horizontal differential for decoded MV | |
1745 * @param dmv_y Vertical differential for decoded MV | |
1746 */ | |
2462 | 1747 #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
|
1748 index = 1 + get_vlc2(gb, vc9_mv_diff_vlc[s->mv_table_index].table,\ |
2462 | 1749 VC9_MV_DIFF_VLC_BITS, 2); \ |
1750 if (index > 36) \ | |
1751 { \ | |
1752 mb_has_coeffs = 1; \ | |
1753 index -= 37; \ | |
1754 } \ | |
1755 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
|
1756 s->mb_intra = 0; \ |
2462 | 1757 if (!index) { _dmv_x = _dmv_y = 0; } \ |
1758 else if (index == 35) \ | |
1759 { \ | |
2474 | 1760 _dmv_x = get_bits(gb, k_x); \ |
1761 _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
|
1762 s->mb_intra = 1; \ |
2462 | 1763 } \ |
1764 else \ | |
1765 { \ | |
1766 index1 = index%6; \ | |
1767 if (hpel_flag && index1 == 5) val = 1; \ | |
1768 else val = 0; \ | |
2474 | 1769 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1770 sign = 0 - (val&1); \ |
1771 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ | |
1772 \ | |
1773 index1 = index/6; \ | |
1774 if (hpel_flag && index1 == 5) val = 1; \ | |
1775 else val = 0; \ | |
2474 | 1776 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1777 sign = 0 - (val&1); \ |
1778 _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
|
1779 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1780 |
2482 | 1781 /** Decode all MBs for an P frame in Simple/Main profile |
1782 * @see 8.1, p(1)15 | |
1783 * @todo TODO: Process the blocks | |
1784 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1785 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1786 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
|
1787 { |
2474 | 1788 MpegEncContext *s = &v->s; |
1789 GetBitContext *gb = &v->s.gb; | |
1790 int current_mb = 0, i; /* MB/Block Position info */ | |
2462 | 1791 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
1792 *p_cbpcy /* Pointer to skip some math */; | |
2474 | 1793 int hybrid_pred; /* Prediction types */ |
2462 | 1794 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
|
1795 int mqdiff, mquant; /* MB quantization */ |
2462 | 1796 int ttmb; /* MB Transform type */ |
1797 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1798 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
|
1799 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
|
1800 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 1801 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
|
1802 int k_x, k_y; /* Long MV fixed bitlength */ |
2462 | 1803 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
|
1804 int index, index1; /* LUT indices */ |
2462 | 1805 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
|
1806 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1807 /* 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
|
1808 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
|
1809 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
|
1810 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
|
1811 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1812 /* Select proper long MV range */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1813 switch (v->mvrange) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1814 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1815 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
|
1816 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
|
1817 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
|
1818 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
|
1819 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1820 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1821 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
|
1822 k_x -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1823 k_y -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1824 |
2462 | 1825 /* Reset CBPCY predictors */ |
2474 | 1826 memset(v->previous_line_cbpcy, 0, s->mb_stride<<2); |
2462 | 1827 |
2474 | 1828 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
|
1829 { |
2462 | 1830 /* Init CBPCY for line */ |
1831 *((uint32_t*)previous_cbpcy) = 0x00000000; | |
1832 p_cbpcy = v->previous_line_cbpcy+4; | |
1833 | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1834 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
|
1835 { |
2462 | 1836 if (v->mv_type_mb_plane.is_raw) |
2474 | 1837 v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 1838 if (v->skip_mb_plane.is_raw) |
2474 | 1839 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
|
1840 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
|
1841 { |
2462 | 1842 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
|
1843 { |
2462 | 1844 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
|
1845 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1846 /* 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
|
1847 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
|
1848 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 1849 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
|
1850 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
|
1851 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1852 GET_MQUANT(); |
2474 | 1853 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
|
1854 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1855 else if (mb_has_coeffs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1856 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1857 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
|
1858 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
|
1859 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
|
1860 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
|
1861 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
|
1862 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
|
1863 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
|
1864 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
|
1865 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
|
1866 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
|
1867 //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
|
1868 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1869 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1870 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1871 if (!v->ttmbf) |
2474 | 1872 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 1873 VC9_TTMB_VLC_BITS, 12); |
1874 /* 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
|
1875 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1876 else //Skipped |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1877 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1878 /* 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
|
1879 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
|
1880 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 1881 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
|
1882 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1883 } //1MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1884 else //4MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1885 { |
2462 | 1886 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
|
1887 { |
2462 | 1888 /* Get CBPCY */ |
1889 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
|
1890 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
|
1891 { |
2462 | 1892 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
|
1893 { |
2462 | 1894 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
|
1895 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1896 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 1897 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
|
1898 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1899 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
|
1900 index /* non-zero pred for that block */) |
2474 | 1901 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
|
1902 if (!v->ttmbf) |
2474 | 1903 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 1904 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
|
1905 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1906 /* TODO: Process blocks wrt cbpcy */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1907 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1908 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1909 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1910 else //Skipped MB |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1911 { |
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++) //All 4 Y blocks |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1913 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1914 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 1915 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
|
1916 |
2462 | 1917 /* TODO: do something */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1918 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1919 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1920 } |
2462 | 1921 |
1922 /* Update for next block */ | |
1923 #if TRACE > 2 | |
2474 | 1924 av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i," |
2462 | 1925 " cbpcy=%i%i%i%i\n", current_mb, |
1926 p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3], | |
1927 previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3], | |
1928 cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]); | |
1929 #endif | |
1930 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); | |
1931 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); | |
1932 current_mb++; | |
2445
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 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1935 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1936 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1937 |
2482 | 1938 /** Decode all MBs for an P frame in Simple/Main profile |
1939 * @todo TODO: Process the blocks | |
1940 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
1941 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1942 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
|
1943 { |
2474 | 1944 MpegEncContext *s = &v->s; |
1945 GetBitContext *gb = &v->s.gb; | |
1946 int current_mb = 0, i /* MB / B postion information */; | |
2462 | 1947 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
|
1948 int mquant, mqdiff; /* MB quant stuff */ |
2462 | 1949 int ttmb; /* MacroBlock transform type */ |
1950 | |
1951 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, | |
1952 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
|
1953 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 1954 int dmv1_x, dmv1_y, dmv2_x, dmv2_y; /* Differential MV components */ |
1955 int k_x, k_y; /* Long MV fixed bitlength */ | |
1956 int hpel_flag; /* Some MB properties */ | |
1957 int index, index1; /* LUT indices */ | |
1958 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
|
1959 |
2462 | 1960 /* Select proper long MV range */ |
1961 switch (v->mvrange) | |
1962 { | |
1963 case 1: k_x = 10; k_y = 9; break; | |
1964 case 2: k_x = 12; k_y = 10; break; | |
1965 case 3: k_x = 13; k_y = 11; break; | |
1966 default: /*case 0 too */ k_x = 9; k_y = 8; break; | |
1967 } | |
1968 hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL | |
1969 k_x -= hpel_flag; | |
1970 k_y -= hpel_flag; | |
1971 | |
1972 /* Select ttmb table depending on pq */ | |
1973 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; | |
1974 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; | |
1975 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; | |
1976 | |
2474 | 1977 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
|
1978 { |
2474 | 1979 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
|
1980 { |
2462 | 1981 if (v->direct_mb_plane.is_raw) |
2474 | 1982 v->direct_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 1983 if (v->skip_mb_plane.is_raw) |
2474 | 1984 v->skip_mb_plane.data[current_mb] = get_bits(gb, 1); |
2462 | 1985 |
1986 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
|
1987 { |
2462 | 1988 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
|
1989 { |
2474 | 1990 b_mv_type = decode012(gb); |
2462 | 1991 if (v->bfraction > 420 /*1/2*/ && |
1992 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
|
1993 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1994 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1995 { |
2462 | 1996 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
|
1997 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
|
1998 { |
2474 | 1999 b_mv_type = decode012(gb); |
2462 | 2000 if (v->bfraction > 420 /*1/2*/ && |
2001 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
|
2002 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2003 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2004 } |
2462 | 2005 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
|
2006 { |
2462 | 2007 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
|
2008 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2009 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2010 if (s->mb_intra /* intra mb */) |
2474 | 2011 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
|
2012 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2013 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2014 { |
2462 | 2015 /* if bmv1 tells MVs are interpolated */ |
2016 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
|
2017 { |
2462 | 2018 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
|
2019 } |
2462 | 2020 /* GET_MVDATA has reset some stuff */ |
2021 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
|
2022 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2023 if (s->mb_intra /* intra_mb */) |
2474 | 2024 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
|
2025 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2026 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2027 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2028 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2029 //End1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2030 if (v->ttmbf) |
2474 | 2031 ttmb = get_vlc2(gb, v->ttmb_vlc->table, |
2462 | 2032 VC9_TTMB_VLC_BITS, 12); |
2033 | |
2034 //End2 | |
2035 for (i=0; i<6; i++) | |
2036 { | |
2037 /* FIXME: process the block */ | |
2038 } | |
2039 | |
2040 current_mb++; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2041 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2042 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2043 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2044 } |
2482 | 2045 /** @} */ //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
|
2046 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2047 #if HAS_ADVANCED_PROFILE |
2482 | 2048 /***********************************************************************/ |
2049 /** | |
2050 * @defgroup adv_mb VC9 Macroblock-level functions in Advanced Profile | |
2051 * @todo TODO: Integrate to MpegEncContext facilities | |
2052 * @todo TODO: Code P, B and BI | |
2053 * @{ | |
2054 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2055 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
|
2056 { |
2474 | 2057 MpegEncContext *s = &v->s; |
2058 GetBitContext *gb = &v->s.gb; | |
2059 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
|
2060 |
2474 | 2061 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
|
2062 { |
2474 | 2063 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
|
2064 { |
2474 | 2065 if (v->ac_pred_plane.is_raw) |
2066 s->ac_pred = get_bits(gb, 1); | |
2067 else | |
2068 s->ac_pred = v->ac_pred_plane.data[current_mb]; | |
2462 | 2069 if (v->condover == 3 && v->over_flags_plane.is_raw) |
2474 | 2070 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
|
2071 GET_MQUANT(); |
2462 | 2072 |
2073 /* TODO: lots */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2074 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2075 current_mb++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2076 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2077 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2078 } |
2482 | 2079 /** @} */ //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
|
2080 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2081 |
2482 | 2082 /** Initialize a VC9/WMV3 decoder |
2083 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2084 * @todo TODO: Decypher remaining bits in extra_data | |
2085 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2086 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
|
2087 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2088 VC9Context *v = avctx->priv_data; |
2474 | 2089 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2090 GetBitContext gb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2091 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2092 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
|
2093 avctx->pix_fmt = PIX_FMT_YUV420P; |
2474 | 2094 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2095 |
2474 | 2096 if(ff_h263_decode_init(avctx) < 0) |
2097 return -1; | |
2098 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
|
2099 |
2462 | 2100 avctx->coded_width = avctx->width; |
2101 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
|
2102 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
|
2103 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2104 int count = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2105 |
2474 | 2106 // looks like WMV3 has a sequence header stored in the extradata |
2107 // advanced sequence header may be before the first frame | |
2108 // the last byte of the extradata is a version number, 1 for the | |
2109 // samples we can decode | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2110 |
2474 | 2111 init_get_bits(&gb, avctx->extradata, avctx->extradata_size); |
2112 | |
2113 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
|
2114 |
2474 | 2115 count = avctx->extradata_size*8 - get_bits_count(&gb); |
2116 if (count>0) | |
2117 { | |
2118 av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", | |
2119 count, get_bits(&gb, count)); | |
2120 } | |
2121 else | |
2122 { | |
2123 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); | |
2124 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2125 } |
2474 | 2126 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
|
2127 |
2474 | 2128 s->mb_width = (avctx->coded_width+15)>>4; |
2129 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
|
2130 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2131 /* Allocate mb bitplanes */ |
2474 | 2132 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2133 return -1; |
2474 | 2134 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2135 return -1; |
2474 | 2136 if (alloc_bitplane(&v->skip_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2137 return -1; |
2474 | 2138 if (alloc_bitplane(&v->direct_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2139 return -1; |
2140 | |
2141 /* For predictors */ | |
2474 | 2142 v->previous_line_cbpcy = (uint8_t *)av_malloc(s->mb_stride*4); |
2462 | 2143 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
|
2144 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2145 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2146 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2147 { |
2474 | 2148 if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2149 return -1; |
2474 | 2150 if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2151 return -1; |
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 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2154 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2155 return 0; |
2474 | 2156 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2157 |
2482 | 2158 /** Decode a VC9/WMV3 frame |
2159 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2160 * @warning Initial try at using MpegEncContext stuff | |
2161 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2162 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
|
2163 void *data, int *data_size, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2164 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
|
2165 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2166 VC9Context *v = avctx->priv_data; |
2474 | 2167 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2168 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
|
2169 AVFrame *pict = data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2170 uint8_t *tmp_buf; |
2474 | 2171 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2172 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2173 //buf_size = 0 -> last frame |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2174 if (!buf_size) return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2175 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2176 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
|
2177 avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2178 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
|
2179 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
|
2180 avctx->width, avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2181 |
2474 | 2182 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
|
2183 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2184 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2185 // search for IDU's |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2186 // FIXME |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2187 uint32_t scp = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2188 int scs = 0, i = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2189 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2190 while (i < buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2191 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2192 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
|
2193 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
|
2194 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2195 if (scp != 0x000001) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2196 break; // eof ? |
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 scs = buf[i++]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2199 |
2474 | 2200 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
|
2201 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2202 switch(scs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2203 { |
2462 | 2204 case 0x0A: //Sequence End Code |
2205 return 0; | |
2206 case 0x0B: //Slice Start Code | |
2207 av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n"); | |
2208 return -1; | |
2209 case 0x0C: //Field start code | |
2210 av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n"); | |
2211 return -1; | |
2212 case 0x0D: //Frame start code | |
2213 break; | |
2214 case 0x0E: //Entry point Start Code | |
2215 if (v->profile <= MAIN_PROFILE) | |
2216 av_log(avctx, AV_LOG_ERROR, | |
2217 "Found an entry point in profile %i\n", v->profile); | |
2474 | 2218 advanced_entry_point_process(avctx, gb); |
2462 | 2219 break; |
2220 case 0x0F: //Sequence header Start Code | |
2474 | 2221 decode_sequence_header(avctx, gb); |
2462 | 2222 break; |
2223 default: | |
2224 av_log(avctx, AV_LOG_ERROR, | |
2225 "Unsupported IDU suffix %lX\n", scs); | |
2226 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2227 |
2474 | 2228 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
|
2229 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2230 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2231 av_abort(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2232 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2233 } |
2474 | 2234 else |
2235 init_get_bits(&v->s.gb, buf, buf_size*8); | |
2236 | |
2237 s->flags= avctx->flags; | |
2238 s->flags2= avctx->flags2; | |
2239 | |
2240 /* no supplementary picture */ | |
2241 if (buf_size == 0) { | |
2242 /* special case for last picture */ | |
2243 if (s->low_delay==0 && s->next_picture_ptr) { | |
2244 *pict= *(AVFrame*)s->next_picture_ptr; | |
2245 s->next_picture_ptr= NULL; | |
2246 | |
2247 *data_size = sizeof(AVFrame); | |
2248 } | |
2249 | |
2250 return 0; | |
2251 } | |
2252 | |
2253 //No IDU - we mimic ff_h263_decode_frame | |
2254 s->bitstream_buffer_size=0; | |
2255 | |
2256 if (!s->context_initialized) { | |
2257 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix | |
2258 return -1; | |
2259 } | |
2260 | |
2261 //we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there | |
2262 if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ | |
2263 s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)]; | |
2264 } | |
2265 #if HAS_ADVANCED_PROFILE | |
2266 if (v->profile > PROFILE_MAIN) | |
2267 ret= advanced_decode_picture_primary_header(v); | |
2268 else | |
2269 #endif | |
2270 ret= standard_decode_picture_primary_header(v); | |
2271 if (ret == FRAME_SKIPED) return buf_size; | |
2272 /* skip if the header was thrashed */ | |
2273 if (ret < 0){ | |
2274 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); | |
2275 return -1; | |
2276 } | |
2277 | |
2278 //No bug workaround yet, no DCT conformance | |
2279 | |
2280 //WMV9 does have resized images | |
2281 if (v->profile <= PROFILE_MAIN && v->multires){ | |
2282 //Parse context stuff in here, don't know how appliable it is | |
2283 } | |
2284 //Not sure about context initialization | |
2285 | |
2286 // for hurry_up==5 | |
2287 s->current_picture.pict_type= s->pict_type; | |
2288 s->current_picture.key_frame= s->pict_type == I_TYPE; | |
2289 | |
2290 /* skip b frames if we dont have reference frames */ | |
2291 if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) | |
2292 return buf_size; //FIXME simulating all buffer consumed | |
2293 /* skip b frames if we are in a hurry */ | |
2294 if(avctx->hurry_up && s->pict_type==B_TYPE) | |
2295 return buf_size; //FIXME simulating all buffer consumed | |
2296 /* skip everything if we are in a hurry>=5 */ | |
2297 if(avctx->hurry_up>=5) | |
2298 return buf_size; //FIXME simulating all buffer consumed | |
2299 | |
2300 if(s->next_p_frame_damaged){ | |
2301 if(s->pict_type==B_TYPE) | |
2302 return buf_size; //FIXME simulating all buffer consumed | |
2303 else | |
2304 s->next_p_frame_damaged=0; | |
2305 } | |
2306 | |
2307 if(MPV_frame_start(s, avctx) < 0) | |
2308 return -1; | |
2309 | |
2310 ff_er_frame_start(s); | |
2311 | |
2312 //wmv9 may or may not have skip bits | |
2313 #if HAS_ADVANCED_PROFILE | |
2314 if (v->profile > PROFILE_MAIN) | |
2315 ret= advanced_decode_picture_secondary_header(v); | |
2316 else | |
2317 #endif | |
2318 ret = standard_decode_picture_secondary_header(v); | |
2319 if (ret<0) return FRAME_SKIPED; //FIXME Non fatal for now | |
2320 | |
2321 //We consider the image coded in only one slice | |
2322 #if HAS_ADVANCED_PROFILE | |
2323 if (v->profile > PROFILE_MAIN) | |
2324 { | |
2325 switch(s->pict_type) | |
2326 { | |
2327 case I_TYPE: ret = advanced_decode_i_mbs(v); break; | |
2328 case P_TYPE: ret = decode_p_mbs(v); break; | |
2329 case B_TYPE: | |
2330 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2331 default: ret = FRAME_SKIPED; | |
2332 } | |
2333 if (ret == FRAME_SKIPED) return buf_size; //We ignore for now failures | |
2334 } | |
2335 else | |
2336 #endif | |
2337 { | |
2338 switch(s->pict_type) | |
2339 { | |
2340 case I_TYPE: ret = standard_decode_i_mbs(v); break; | |
2341 case P_TYPE: ret = decode_p_mbs(v); break; | |
2342 case B_TYPE: | |
2343 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2344 default: ret = FRAME_SKIPED; | |
2345 } | |
2346 if (ret == FRAME_SKIPED) return buf_size; | |
2347 } | |
2348 | |
2349 ff_er_frame_end(s); | |
2350 | |
2351 MPV_frame_end(s); | |
2352 | |
2353 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); | |
2354 assert(s->current_picture.pict_type == s->pict_type); | |
2355 if(s->pict_type==B_TYPE || s->low_delay){ | |
2356 *pict= *(AVFrame*)&s->current_picture; | |
2357 ff_print_debug_info(s, pict); | |
2358 } else { | |
2359 *pict= *(AVFrame*)&s->last_picture; | |
2360 if(pict) | |
2361 ff_print_debug_info(s, pict); | |
2362 } | |
2363 | |
2364 /* Return the Picture timestamp as the frame number */ | |
2365 /* we substract 1 because it is added on utils.c */ | |
2366 avctx->frame_number = s->picture_number - 1; | |
2367 | |
2368 /* dont output the last pic after seeking */ | |
2369 if(s->last_picture_ptr || s->low_delay) | |
2370 *data_size = sizeof(AVFrame); | |
2371 | |
2462 | 2372 av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n", |
2474 | 2373 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
|
2374 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2375 /* Fake consumption of all data */ |
2462 | 2376 *data_size = len; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2377 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
|
2378 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2379 |
2482 | 2380 /** Close a VC9/WMV3 decoder |
2381 * @warning Initial try at using MpegEncContext stuff | |
2382 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2383 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
|
2384 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2385 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2386 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2387 #if HAS_ADVANCED_PROFILE |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2388 av_freep(&v->hrd_rate); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2389 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
|
2390 #endif |
2474 | 2391 MPV_common_end(&v->s); |
2392 free_bitplane(&v->mv_type_mb_plane); | |
2393 free_bitplane(&v->skip_mb_plane); | |
2394 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
|
2395 return 0; |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2398 AVCodec vc9_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2399 "vc9", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2400 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2401 CODEC_ID_VC9, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2402 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2403 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2404 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2405 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2406 vc9_decode_frame, |
2453 | 2407 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2408 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2409 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2410 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2411 AVCodec wmv3_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2412 "wmv3", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2413 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2414 CODEC_ID_WMV3, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2415 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2416 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2417 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2418 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2419 vc9_decode_frame, |
2453 | 2420 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2421 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2422 }; |