annotate dv.c @ 1036:c7922c5becf6 libavcodec

DV audio decoder by Roman Shaposhnick
author bellard
date Mon, 27 Jan 2003 09:21:30 +0000
parents 1f9afd8b9131
children b32afefe7d33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
1 /*
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
2 * DV decoder
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
3 * Copyright (c) 2002 Fabrice Bellard.
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
4 *
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
9 *
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
14 *
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
18 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
19 #include "avcodec.h"
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
20 #include "dsputil.h"
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
21 #include "mpegvideo.h"
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
22 #include "simple_idct.h"
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
23
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
24 #define NTSC_FRAME_SIZE 120000
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
25 #define PAL_FRAME_SIZE 144000
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
26
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
27 #define TEX_VLC_BITS 9
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
28
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
29 typedef struct DVVideoDecodeContext {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
30 AVCodecContext *avctx;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
31 GetBitContext gb;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
32 VLC *vlc;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
33 int sampling_411; /* 0 = 420, 1 = 411 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
34 int width, height;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
35 UINT8 *current_picture[3]; /* picture structure */
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 903
diff changeset
36 AVFrame picture;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
37 int linesize[3];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
38 DCTELEM block[5*6][64] __align8;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
39 UINT8 dv_zigzag[2][64];
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
40 UINT8 idct_permutation[64];
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
41 /* XXX: move it to static storage ? */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
42 UINT8 dv_shift[2][22][64];
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
43 void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
44 } DVVideoDecodeContext;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
45
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
46 #include "dvdata.h"
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
47
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
48 static VLC dv_vlc;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
49 /* XXX: also include quantization */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
50 static RL_VLC_ELEM *dv_rl_vlc[1];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
51
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
52 static void dv_build_unquantize_tables(DVVideoDecodeContext *s)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
53 {
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
54 int i, q, j;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
55
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
56 /* NOTE: max left shift is 6 */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
57 for(q = 0; q < 22; q++) {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
58 /* 88 unquant */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
59 for(i = 1; i < 64; i++) {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
60 /* 88 table */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
61 j = s->idct_permutation[i];
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
62 s->dv_shift[0][q][j] =
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
63 dv_quant_shifts[q][dv_88_areas[i]] + 1;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
64 }
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
65
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
66 /* 248 unquant */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
67 for(i = 1; i < 64; i++) {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
68 /* 248 table */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
69 s->dv_shift[1][q][i] =
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
70 dv_quant_shifts[q][dv_248_areas[i]] + 1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
71 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
72 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
73 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
74
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
75 static int dvvideo_decode_init(AVCodecContext *avctx)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
76 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
77 DVVideoDecodeContext *s = avctx->priv_data;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
78 MpegEncContext s2;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
79 static int done;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
80
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
81 if (!done) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
82 int i;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
83
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
84 done = 1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
85
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
86 /* NOTE: as a trick, we use the fact the no codes are unused
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
87 to accelerate the parsing of partial codes */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
88 init_vlc(&dv_vlc, TEX_VLC_BITS, NB_DV_VLC,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
89 dv_vlc_len, 1, 1, dv_vlc_bits, 2, 2);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
90
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
91 dv_rl_vlc[0] = av_malloc(dv_vlc.table_size * sizeof(RL_VLC_ELEM));
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
92 for(i = 0; i < dv_vlc.table_size; i++){
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
93 int code= dv_vlc.table[i][0];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
94 int len = dv_vlc.table[i][1];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
95 int level, run;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
96
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
97 if(len<0){ //more bits needed
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
98 run= 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
99 level= code;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
100 } else if (code == (NB_DV_VLC - 1)) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
101 /* EOB */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
102 run = 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
103 level = 256;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
104 } else {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
105 run= dv_vlc_run[code] + 1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
106 level= dv_vlc_level[code];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
107 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
108 dv_rl_vlc[0][i].len = len;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
109 dv_rl_vlc[0][i].level = level;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
110 dv_rl_vlc[0][i].run = run;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
111 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
112 }
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
113
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
114 /* ugly way to get the idct & scantable */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
115 /* XXX: fix it */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
116 memset(&s2, 0, sizeof(MpegEncContext));
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
117 s2.avctx = avctx;
853
eacc2dd8fd9d * using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents: 848
diff changeset
118 dsputil_init(&s2.dsp, avctx->dsp_mask);
726
a91203b34e71 moved dct init out from mpv_common_init to dct_common_init (for less-uglier way for dv)
al3x
parents: 725
diff changeset
119 if (DCT_common_init(&s2) < 0)
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
120 return -1;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
121
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
122 s->idct_put[0] = s2.idct_put;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
123 memcpy(s->idct_permutation, s2.idct_permutation, 64);
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
124 memcpy(s->dv_zigzag[0], s2.intra_scantable.permutated, 64);
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
125
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
126 /* XXX: use MMX also for idct248 */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
127 s->idct_put[1] = simple_idct248_put;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
128 memcpy(s->dv_zigzag[1], dv_248_zigzag, 64);
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
129
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
130 /* XXX: do it only for constant case */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
131 dv_build_unquantize_tables(s);
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
132
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
133 return 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
134 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
135
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
136 //#define VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
137
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
138 typedef struct BlockInfo {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
139 const UINT8 *shift_table;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
140 const UINT8 *scan_table;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
141 UINT8 pos; /* position in block */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
142 UINT8 eob_reached; /* true if EOB has been reached */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
143 UINT8 dct_mode;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
144 UINT8 partial_bit_count;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
145 UINT16 partial_bit_buffer;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
146 int shift_offset;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
147 } BlockInfo;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
148
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
149 /* block size in bits */
726
a91203b34e71 moved dct init out from mpv_common_init to dct_common_init (for less-uglier way for dv)
al3x
parents: 725
diff changeset
150 static const UINT16 block_sizes[6] = {
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
151 112, 112, 112, 112, 80, 80
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
152 };
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
153
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
154 #ifndef ALT_BITSTREAM_READER
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
155 #error only works with ALT_BITSTREAM_READER
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
156 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
157
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
158 /* decode ac coefs */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
159 static void dv_decode_ac(DVVideoDecodeContext *s,
1008
fb6cbb8a04a3 fixing DCTELEM != short
michaelni
parents: 949
diff changeset
160 BlockInfo *mb, DCTELEM *block, int last_index)
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
161 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
162 int last_re_index;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
163 int shift_offset = mb->shift_offset;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
164 const UINT8 *scan_table = mb->scan_table;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
165 const UINT8 *shift_table = mb->shift_table;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
166 int pos = mb->pos;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
167 int level, pos1, sign, run;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
168 int partial_bit_count;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
169
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
170 OPEN_READER(re, &s->gb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
171
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
172 #ifdef VLC_DEBUG
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
173 printf("start\n");
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
174 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
175
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
176 /* if we must parse a partial vlc, we do it here */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
177 partial_bit_count = mb->partial_bit_count;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
178 if (partial_bit_count > 0) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
179 UINT8 buf[4];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
180 UINT32 v;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
181 int l, l1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
182 GetBitContext gb1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
183
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
184 /* build the dummy bit buffer */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
185 l = 16 - partial_bit_count;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
186 UPDATE_CACHE(re, &s->gb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
187 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
188 printf("show=%04x\n", SHOW_UBITS(re, &s->gb, 16));
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
189 #endif
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
190 v = (mb->partial_bit_buffer << l) | SHOW_UBITS(re, &s->gb, l);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
191 buf[0] = v >> 8;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
192 buf[1] = v;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
193 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
194 printf("v=%04x cnt=%d %04x\n",
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
195 v, partial_bit_count, (mb->partial_bit_buffer << l));
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
196 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
197 /* try to read the codeword */
1025
1f9afd8b9131 GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents: 1008
diff changeset
198 init_get_bits(&gb1, buf, 4*8);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
199 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
200 OPEN_READER(re1, &gb1);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
201 UPDATE_CACHE(re1, &gb1);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
202 GET_RL_VLC(level, run, re1, &gb1, dv_rl_vlc[0],
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
203 TEX_VLC_BITS, 2);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
204 l = re1_index;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
205 CLOSE_READER(re1, &gb1);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
206 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
207 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
208 printf("****run=%d level=%d size=%d\n", run, level, l);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
209 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
210 /* compute codeword length */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
211 l1 = (level != 256 && level != 0);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
212 /* if too long, we cannot parse */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
213 l -= partial_bit_count;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
214 if ((re_index + l + l1) > last_index)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
215 return;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
216 /* skip read bits */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
217 last_re_index = 0; /* avoid warning */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
218 re_index += l;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
219 /* by definition, if we can read the vlc, all partial bits
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
220 will be read (otherwise we could have read the vlc before) */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
221 mb->partial_bit_count = 0;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
222 UPDATE_CACHE(re, &s->gb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
223 goto handle_vlc;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
224 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
225
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
226 /* get the AC coefficients until last_index is reached */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
227 for(;;) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
228 UPDATE_CACHE(re, &s->gb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
229 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
230 printf("%2d: bits=%04x index=%d\n",
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
231 pos, SHOW_UBITS(re, &s->gb, 16), re_index);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
232 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
233 last_re_index = re_index;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
234 GET_RL_VLC(level, run, re, &s->gb, dv_rl_vlc[0],
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
235 TEX_VLC_BITS, 2);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
236 handle_vlc:
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
237 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
238 printf("run=%d level=%d\n", run, level);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
239 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
240 if (level == 256) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
241 if (re_index > last_index) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
242 cannot_read:
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
243 /* put position before read code */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
244 re_index = last_re_index;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
245 mb->eob_reached = 0;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
246 break;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
247 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
248 /* EOB */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
249 mb->eob_reached = 1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
250 break;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
251 } else if (level != 0) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
252 if ((re_index + 1) > last_index)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
253 goto cannot_read;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
254 sign = SHOW_SBITS(re, &s->gb, 1);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
255 level = (level ^ sign) - sign;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
256 LAST_SKIP_BITS(re, &s->gb, 1);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
257 pos += run;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
258 /* error */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
259 if (pos >= 64) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
260 goto read_error;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
261 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
262 pos1 = scan_table[pos];
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
263 level = level << (shift_table[pos1] + shift_offset);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
264 block[pos1] = level;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
265 // printf("run=%d level=%d shift=%d\n", run, level, shift_table[pos1]);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
266 } else {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
267 if (re_index > last_index)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
268 goto cannot_read;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
269 /* level is zero: means run without coding. No
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
270 sign is coded */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
271 pos += run;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
272 /* error */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
273 if (pos >= 64) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
274 read_error:
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
275 #if defined(VLC_DEBUG) || 1
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
276 printf("error pos=%d\n", pos);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
277 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
278 /* for errors, we consider the eob is reached */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
279 mb->eob_reached = 1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
280 break;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
281 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
282 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
283 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
284 CLOSE_READER(re, &s->gb);
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
285 mb->pos = pos;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
286 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
287
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
288 static inline void bit_copy(PutBitContext *pb, GetBitContext *gb, int bits_left)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
289 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
290 while (bits_left >= 16) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
291 put_bits(pb, 16, get_bits(gb, 16));
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
292 bits_left -= 16;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
293 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
294 if (bits_left > 0) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
295 put_bits(pb, bits_left, get_bits(gb, bits_left));
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
296 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
297 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
298
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
299 /* mb_x and mb_y are in units of 8 pixels */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
300 static inline void dv_decode_video_segment(DVVideoDecodeContext *s,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
301 UINT8 *buf_ptr1,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
302 const UINT16 *mb_pos_ptr)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
303 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
304 int quant, dc, dct_mode, class1, j;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
305 int mb_index, mb_x, mb_y, v, last_index;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
306 DCTELEM *block, *block1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
307 int c_offset, bits_left;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
308 UINT8 *y_ptr;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
309 BlockInfo mb_data[5 * 6], *mb, *mb1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
310 void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
311 UINT8 *buf_ptr;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
312 PutBitContext pb, vs_pb;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
313 UINT8 mb_bit_buffer[80 + 4]; /* allow some slack */
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
314 int mb_bit_count;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
315 UINT8 vs_bit_buffer[5 * 80 + 4]; /* allow some slack */
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
316 int vs_bit_count;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
317
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
318 memset(s->block, 0, sizeof(s->block));
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
319
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
320 /* pass 1 : read DC and AC coefficients in blocks */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
321 buf_ptr = buf_ptr1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
322 block1 = &s->block[0][0];
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
323 mb1 = mb_data;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
324 init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80, NULL, NULL);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
325 vs_bit_count = 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
326 for(mb_index = 0; mb_index < 5; mb_index++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
327 /* skip header */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
328 quant = buf_ptr[3] & 0x0f;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
329 buf_ptr += 4;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
330 init_put_bits(&pb, mb_bit_buffer, 80, NULL, NULL);
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
331 mb_bit_count = 0;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
332 mb = mb1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
333 block = block1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
334 for(j = 0;j < 6; j++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
335 /* NOTE: size is not important here */
1025
1f9afd8b9131 GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents: 1008
diff changeset
336 init_get_bits(&s->gb, buf_ptr, 14*8);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
337
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
338 /* get the dc */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
339 dc = get_bits(&s->gb, 9);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
340 dc = (dc << (32 - 9)) >> (32 - 9);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
341 dct_mode = get_bits1(&s->gb);
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
342 mb->dct_mode = dct_mode;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
343 mb->scan_table = s->dv_zigzag[dct_mode];
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
344 class1 = get_bits(&s->gb, 2);
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
345 mb->shift_offset = (class1 == 3);
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
346 mb->shift_table = s->dv_shift[dct_mode]
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
347 [quant + dv_quant_offset[class1]];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
348 dc = dc << 2;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
349 /* convert to unsigned because 128 is not added in the
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
350 standard IDCT */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
351 dc += 1024;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
352 block[0] = dc;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
353 last_index = block_sizes[j];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
354 buf_ptr += last_index >> 3;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
355 mb->pos = 0;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
356 mb->partial_bit_count = 0;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
357
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
358 dv_decode_ac(s, mb, block, last_index);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
359
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
360 /* write the remaining bits in a new buffer only if the
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
361 block is finished */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
362 bits_left = last_index - s->gb.index;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
363 if (mb->eob_reached) {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
364 mb->partial_bit_count = 0;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
365 mb_bit_count += bits_left;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
366 bit_copy(&pb, &s->gb, bits_left);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
367 } else {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
368 /* should be < 16 bits otherwise a codeword could have
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
369 been parsed */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
370 mb->partial_bit_count = bits_left;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
371 mb->partial_bit_buffer = get_bits(&s->gb, bits_left);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
372 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
373 block += 64;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
374 mb++;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
375 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
376
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
377 flush_put_bits(&pb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
378
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
379 /* pass 2 : we can do it just after */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
380 #ifdef VLC_DEBUG
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
381 printf("***pass 2 size=%d\n", mb_bit_count);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
382 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
383 block = block1;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
384 mb = mb1;
1025
1f9afd8b9131 GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents: 1008
diff changeset
385 init_get_bits(&s->gb, mb_bit_buffer, 80*8);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
386 for(j = 0;j < 6; j++) {
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
387 if (!mb->eob_reached && s->gb.index < mb_bit_count) {
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
388 dv_decode_ac(s, mb, block, mb_bit_count);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
389 /* if still not finished, no need to parse other blocks */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
390 if (!mb->eob_reached) {
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
391 /* we could not parse the current AC coefficient,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
392 so we add the remaining bytes */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
393 bits_left = mb_bit_count - s->gb.index;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
394 if (bits_left > 0) {
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
395 mb->partial_bit_count += bits_left;
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
396 mb->partial_bit_buffer =
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
397 (mb->partial_bit_buffer << bits_left) |
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
398 get_bits(&s->gb, bits_left);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
399 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
400 goto next_mb;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
401 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
402 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
403 block += 64;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
404 mb++;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
405 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
406 /* all blocks are finished, so the extra bytes can be used at
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
407 the video segment level */
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
408 bits_left = mb_bit_count - s->gb.index;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
409 vs_bit_count += bits_left;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
410 bit_copy(&vs_pb, &s->gb, bits_left);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
411 next_mb:
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
412 mb1 += 6;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
413 block1 += 6 * 64;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
414 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
415
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
416 /* we need a pass other the whole video segment */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
417 flush_put_bits(&vs_pb);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
418
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
419 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
420 printf("***pass 3 size=%d\n", vs_bit_count);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
421 #endif
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
422 block = &s->block[0][0];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
423 mb = mb_data;
1025
1f9afd8b9131 GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents: 1008
diff changeset
424 init_get_bits(&s->gb, vs_bit_buffer, 5 * 80*8);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
425 for(mb_index = 0; mb_index < 5; mb_index++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
426 for(j = 0;j < 6; j++) {
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
427 if (!mb->eob_reached) {
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
428 #ifdef VLC_DEBUG
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
429 printf("start %d:%d\n", mb_index, j);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
430 #endif
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
431 dv_decode_ac(s, mb, block, vs_bit_count);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
432 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
433 block += 64;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
434 mb++;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
435 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
436 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
437
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
438 /* compute idct and place blocks */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
439 block = &s->block[0][0];
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
440 mb = mb_data;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
441 for(mb_index = 0; mb_index < 5; mb_index++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
442 v = *mb_pos_ptr++;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
443 mb_x = v & 0xff;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
444 mb_y = v >> 8;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
445 y_ptr = s->current_picture[0] + (mb_y * s->linesize[0] * 8) + (mb_x * 8);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
446 if (s->sampling_411)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
447 c_offset = (mb_y * s->linesize[1] * 8) + ((mb_x >> 2) * 8);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
448 else
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
449 c_offset = ((mb_y >> 1) * s->linesize[1] * 8) + ((mb_x >> 1) * 8);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
450 for(j = 0;j < 6; j++) {
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
451 idct_put = s->idct_put[mb->dct_mode];
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
452 if (j < 4) {
737
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
453 if (s->sampling_411 && mb_x < (704 / 8)) {
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
454 /* NOTE: at end of line, the macroblock is handled as 420 */
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
455 idct_put(y_ptr + (j * 8), s->linesize[0], block);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
456 } else {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
457 idct_put(y_ptr + ((j & 1) * 8) + ((j >> 1) * 8 * s->linesize[0]),
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
458 s->linesize[0], block);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
459 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
460 } else {
737
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
461 if (s->sampling_411 && mb_x >= (704 / 8)) {
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
462 uint8_t pixels[64], *c_ptr, *c_ptr1, *ptr;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
463 int y, linesize;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
464 /* NOTE: at end of line, the macroblock is handled as 420 */
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
465 idct_put(pixels, 8, block);
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
466 linesize = s->linesize[6 - j];
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
467 c_ptr = s->current_picture[6 - j] + c_offset;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
468 ptr = pixels;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
469 for(y = 0;y < 8; y++) {
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
470 /* convert to 411P */
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
471 c_ptr1 = c_ptr + linesize;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
472 c_ptr1[0] = c_ptr[0] = (ptr[0] + ptr[1]) >> 1;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
473 c_ptr1[1] = c_ptr[1] = (ptr[2] + ptr[3]) >> 1;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
474 c_ptr1[2] = c_ptr[2] = (ptr[4] + ptr[5]) >> 1;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
475 c_ptr1[3] = c_ptr[3] = (ptr[6] + ptr[7]) >> 1;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
476 c_ptr += linesize * 2;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
477 ptr += 8;
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
478 }
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
479 } else {
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
480 /* don't ask me why they inverted Cb and Cr ! */
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
481 idct_put(s->current_picture[6 - j] + c_offset,
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
482 s->linesize[6 - j], block);
248a752a4c0e fixed NTSC end of line bug
bellard
parents: 734
diff changeset
483 }
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
484 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
485 block += 64;
725
eac6c71ef30f simplified parsing - added MMX idct support
bellard
parents: 723
diff changeset
486 mb++;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
487 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
488 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
489 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
490
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
491
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
492 /* NOTE: exactly one frame must be given (120000 bytes for NTSC,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
493 144000 bytes for PAL) */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
494 static int dvvideo_decode_frame(AVCodecContext *avctx,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
495 void *data, int *data_size,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
496 UINT8 *buf, int buf_size)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
497 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
498 DVVideoDecodeContext *s = avctx->priv_data;
862
058194d7ade6 * fixing some minor const warnings
kabi
parents: 853
diff changeset
499 int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
500 UINT8 *buf_ptr;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
501 const UINT16 *mb_pos_ptr;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
502
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
503 /* parse id */
1025
1f9afd8b9131 GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents: 1008
diff changeset
504 init_get_bits(&s->gb, buf, buf_size*8);
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
505 sct = get_bits(&s->gb, 3);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
506 if (sct != 0)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
507 return -1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
508 skip_bits(&s->gb, 5);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
509 get_bits(&s->gb, 4); /* dsn (sequence number */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
510 get_bits(&s->gb, 1); /* fsc (channel number) */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
511 skip_bits(&s->gb, 3);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
512 get_bits(&s->gb, 8); /* dbn (diff block number 0-134) */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
513
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
514 dsf = get_bits(&s->gb, 1); /* 0 = NTSC 1 = PAL */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
515 if (get_bits(&s->gb, 1) != 0)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
516 return -1;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
517 skip_bits(&s->gb, 11);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
518 apt = get_bits(&s->gb, 3); /* apt */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
519
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
520 get_bits(&s->gb, 1); /* tf1 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
521 skip_bits(&s->gb, 4);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
522 get_bits(&s->gb, 3); /* ap1 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
523
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
524 get_bits(&s->gb, 1); /* tf2 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
525 skip_bits(&s->gb, 4);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
526 get_bits(&s->gb, 3); /* ap2 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
527
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
528 get_bits(&s->gb, 1); /* tf3 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
529 skip_bits(&s->gb, 4);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
530 get_bits(&s->gb, 3); /* ap3 */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
531
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
532 /* init size */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
533 width = 720;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
534 if (dsf) {
848
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
535 avctx->frame_rate = 25 * FRAME_RATE_BASE;
738
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
536 packet_size = PAL_FRAME_SIZE;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
537 height = 576;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
538 nb_dif_segs = 12;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
539 } else {
848
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
540 avctx->frame_rate = 30 * FRAME_RATE_BASE;
738
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
541 packet_size = NTSC_FRAME_SIZE;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
542 height = 480;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
543 nb_dif_segs = 10;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
544 }
738
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
545 /* NOTE: we only accept several full frames */
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
546 if (buf_size < packet_size)
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
547 return -1;
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
548
733
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
549 /* XXX: is it correct to assume that 420 is always used in PAL
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
550 mode ? */
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
551 s->sampling_411 = !dsf;
848
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
552 if (s->sampling_411) {
733
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
553 mb_pos_ptr = dv_place_411;
848
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
554 avctx->pix_fmt = PIX_FMT_YUV411P;
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
555 } else {
733
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
556 mb_pos_ptr = dv_place_420;
848
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
557 avctx->pix_fmt = PIX_FMT_YUV420P;
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
558 }
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
559
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
560 avctx->width = width;
c075abb7fb3c 10l - set pixelfmt (colorspace) _before_ calling get_buffer() callback
arpi_esp
parents: 835
diff changeset
561 avctx->height = height;
733
7da52fc20726 DV ntsc support, 411P colorspace added
arpi_esp
parents: 726
diff changeset
562
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
563 s->picture.reference= 0;
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
564 if(avctx->get_buffer(avctx, &s->picture) < 0) {
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
565 fprintf(stderr, "get_buffer() failed\n");
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
566 return -1;
835
9cec9eab681f * DR1 support
kabi
parents: 738
diff changeset
567 }
9cec9eab681f * DR1 support
kabi
parents: 738
diff changeset
568
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
569 for(i=0;i<3;i++) {
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
570 s->current_picture[i] = s->picture.data[i];
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
571 s->linesize[i] = s->picture.linesize[i];
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
572 if (!s->current_picture[i])
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
573 return -1;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
574 }
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
575 s->width = width;
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
576 s->height = height;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
577
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
578 /* for each DIF segment */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
579 buf_ptr = buf;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
580 for (ds = 0; ds < nb_dif_segs; ds++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
581 buf_ptr += 6 * 80; /* skip DIF segment header */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
582
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
583 for(vs = 0; vs < 27; vs++) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
584 if ((vs % 3) == 0) {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
585 /* skip audio block */
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
586 buf_ptr += 80;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
587 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
588 dv_decode_video_segment(s, buf_ptr, mb_pos_ptr);
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
589 buf_ptr += 5 * 80;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
590 mb_pos_ptr += 5;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
591 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
592 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
593
734
2d6b3e3d6c6f 10l - MMX/FPU state was not restored, causing nonsense fpu behaviour in caller (mplayer)
arpi_esp
parents: 733
diff changeset
594 emms_c();
2d6b3e3d6c6f 10l - MMX/FPU state was not restored, causing nonsense fpu behaviour in caller (mplayer)
arpi_esp
parents: 733
diff changeset
595
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
596 /* return image */
925
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 903
diff changeset
597 *data_size = sizeof(AVFrame);
7fccaa0d699d AVVideoFrame -> AVFrame
michaelni
parents: 903
diff changeset
598 *(AVFrame*)data= s->picture;
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
599
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
600 avctx->release_buffer(avctx, &s->picture);
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
601
738
044307862b4b support buffers containing more than one frame
bellard
parents: 737
diff changeset
602 return packet_size;
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
603 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
604
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
605 static int dvvideo_decode_end(AVCodecContext *avctx)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
606 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
607 DVVideoDecodeContext *s = avctx->priv_data;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
608 int i;
903
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
609
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
610 if(avctx->get_buffer == avcodec_default_get_buffer){
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
611 for(i=0; i<4; i++){
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
612 av_freep(&s->picture.base[i]);
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
613 s->picture.data[i]= NULL;
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
614 }
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
615 av_freep(&s->picture.opaque);
22ee74da2cd3 cleanup
michaelni
parents: 864
diff changeset
616 }
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
617
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
618 return 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
619 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
620
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
621 AVCodec dvvideo_decoder = {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
622 "dvvideo",
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
623 CODEC_TYPE_VIDEO,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
624 CODEC_ID_DVVIDEO,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
625 sizeof(DVVideoDecodeContext),
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
626 dvvideo_decode_init,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
627 NULL,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
628 dvvideo_decode_end,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
629 dvvideo_decode_frame,
835
9cec9eab681f * DR1 support
kabi
parents: 738
diff changeset
630 CODEC_CAP_DR1,
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
631 NULL
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
632 };
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
633
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
634 typedef struct DVAudioDecodeContext {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
635 AVCodecContext *avctx;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
636 GetBitContext gb;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
637 } DVAudioDecodeContext;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
638
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
639 static int dvaudio_decode_init(AVCodecContext *avctx)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
640 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
641 // DVAudioDecodeContext *s = avctx->priv_data;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
642 return 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
643 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
644
1036
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
645 static UINT16 dv_audio_12to16(UINT16 sample)
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
646 {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
647 UINT16 shift, result;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
648
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
649 sample = (sample < 0x800) ? sample : sample | 0xf000;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
650 shift = (sample & 0xf00) >> 8;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
651
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
652 if (shift < 0x2 || shift > 0xd) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
653 result = sample;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
654 } else if (shift < 0x8) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
655 shift--;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
656 result = (sample - (256 * shift)) << shift;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
657 } else {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
658 shift = 0xe - shift;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
659 result = ((sample + ((256 * shift) + 1)) << shift) - 1;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
660 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
661
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
662 return result;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
663 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
664
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
665 /* NOTE: exactly one frame must be given (120000 bytes for NTSC,
1036
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
666 144000 bytes for PAL)
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
667
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
668 There's a couple of assumptions being made here:
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
669 1. We don't do any kind of audio error correction. It means,
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
670 that erroneous samples 0x8000 are being passed upwards.
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
671 Do we need to silence erroneous samples ? Average them ?
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
672 2. We don't do software emphasis.
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
673 3. We are not checking for 'speed' argument being valid.
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
674 4. Audio is always returned as 16bit linear samples: 12bit
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
675 nonlinear samples are converted into 16bit linear ones.
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
676 */
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
677 static int dvaudio_decode_frame(AVCodecContext *avctx,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
678 void *data, int *data_size,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
679 UINT8 *buf, int buf_size)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
680 {
1036
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
681 DVVideoDecodeContext *s = avctx->priv_data;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
682 const UINT16 (*unshuffle)[9];
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
683 int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
684 UINT16 lc, rc;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
685 UINT8 *buf_ptr;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
686
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
687 /* parse id */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
688 init_get_bits(&s->gb, &buf[AAUX_OFFSET], 5*8);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
689 i = get_bits(&s->gb, 8);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
690 if (i != 0x50) { /* No audio ? */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
691 *data_size = 0;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
692 return buf_size;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
693 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
694
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
695 get_bits(&s->gb, 1); /* 0 - locked audio, 1 - unlocked audio */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
696 skip_bits(&s->gb, 1);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
697 smpls = get_bits(&s->gb, 6); /* samples in this frame - min. samples */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
698
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
699 skip_bits(&s->gb, 8);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
700
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
701 skip_bits(&s->gb, 2);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
702 sys = get_bits(&s->gb, 1); /* 0 - 60 fields, 1 = 50 fields */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
703 skip_bits(&s->gb, 5);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
704
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
705 get_bits(&s->gb, 1); /* 0 - emphasis on, 1 - emphasis off */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
706 get_bits(&s->gb, 1); /* 0 - reserved, 1 - emphasis time constant 50/15us */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
707 freq = get_bits(&s->gb, 3); /* 0 - 48KHz, 1 - 44,1kHz, 2 - 32 kHz */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
708 quant = get_bits(&s->gb, 3); /* 0 - 16bit linear, 1 - 12bit nonlinear */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
709
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
710 if (quant > 1)
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
711 return -1; /* Unsupported quantization */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
712
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
713 avctx->sample_rate = dv_audio_frequency[freq];
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
714 // What about:
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
715 // avctx->bit_rate =
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
716 // avctx->frame_size =
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
717
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
718 *data_size = (dv_audio_min_samples[sys][freq] + smpls) *
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
719 avctx->channels * 2;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
720
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
721 if (sys) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
722 nb_dif_segs = 12;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
723 stride = 108;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
724 unshuffle = dv_place_audio50;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
725 } else {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
726 nb_dif_segs = 10;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
727 stride = 90;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
728 unshuffle = dv_place_audio60;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
729 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
730
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
731 /* for each DIF segment */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
732 buf_ptr = buf;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
733 for (difseg = 0; difseg < nb_dif_segs; difseg++) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
734 buf_ptr += 6 * 80; /* skip DIF segment header */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
735 for (ad = 0; ad < 9; ad++) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
736
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
737 for (dp = 8; dp < 80; dp+=2) {
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
738 if (quant == 0) { /* 16bit quantization */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
739 i = unshuffle[difseg][ad] + (dp - 8)/2 * stride;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
740 ((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1];
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
741 } else { /* 12bit quantization */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
742 if (difseg >= nb_dif_segs/2)
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
743 goto out; /* We're not doing 4ch at this time */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
744
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
745 lc = ((UINT16)buf_ptr[dp] << 4) |
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
746 ((UINT16)buf_ptr[dp+2] >> 4);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
747 rc = ((UINT16)buf_ptr[dp+1] << 4) |
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
748 ((UINT16)buf_ptr[dp+2] & 0x0f);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
749 lc = dv_audio_12to16(lc);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
750 rc = dv_audio_12to16(rc);
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
751
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
752 i = unshuffle[difseg][ad] + (dp - 8)/3 * stride;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
753 ((short *)data)[i] = lc;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
754 i = unshuffle[difseg+nb_dif_segs/2][ad] + (dp - 8)/3 * stride;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
755 ((short *)data)[i] = rc;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
756 ++dp;
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
757 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
758 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
759
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
760 buf_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
761 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
762 }
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
763
c7922c5becf6 DV audio decoder by Roman Shaposhnick
bellard
parents: 1025
diff changeset
764 out:
723
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
765 return buf_size;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
766 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
767
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
768 static int dvaudio_decode_end(AVCodecContext *avctx)
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
769 {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
770 // DVAudioDecodeContext *s = avctx->priv_data;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
771 return 0;
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
772 }
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
773
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
774 AVCodec dvaudio_decoder = {
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
775 "dvaudio",
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
776 CODEC_TYPE_AUDIO,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
777 CODEC_ID_DVAUDIO,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
778 sizeof(DVAudioDecodeContext),
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
779 dvaudio_decode_init,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
780 NULL,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
781 dvaudio_decode_end,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
782 dvaudio_decode_frame,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
783 0,
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
784 NULL
50f7e3bef20f first working version of DV video decoder
bellard
parents:
diff changeset
785 };