annotate vc9.c @ 2671:5619d89d243a libavcodec

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