Mercurial > libavcodec.hg
comparison dv.c @ 1064:b32afefe7d33 libavcodec
* UINTX -> uintx_t INTX -> intx_t
author | kabi |
---|---|
date | Tue, 11 Feb 2003 16:35:48 +0000 |
parents | c7922c5becf6 |
children | 6da5ae9ee199 |
comparison
equal
deleted
inserted
replaced
1063:fdeac9642346 | 1064:b32afefe7d33 |
---|---|
30 AVCodecContext *avctx; | 30 AVCodecContext *avctx; |
31 GetBitContext gb; | 31 GetBitContext gb; |
32 VLC *vlc; | 32 VLC *vlc; |
33 int sampling_411; /* 0 = 420, 1 = 411 */ | 33 int sampling_411; /* 0 = 420, 1 = 411 */ |
34 int width, height; | 34 int width, height; |
35 UINT8 *current_picture[3]; /* picture structure */ | 35 uint8_t *current_picture[3]; /* picture structure */ |
36 AVFrame picture; | 36 AVFrame picture; |
37 int linesize[3]; | 37 int linesize[3]; |
38 DCTELEM block[5*6][64] __align8; | 38 DCTELEM block[5*6][64] __align8; |
39 UINT8 dv_zigzag[2][64]; | 39 uint8_t dv_zigzag[2][64]; |
40 UINT8 idct_permutation[64]; | 40 uint8_t idct_permutation[64]; |
41 /* XXX: move it to static storage ? */ | 41 /* XXX: move it to static storage ? */ |
42 UINT8 dv_shift[2][22][64]; | 42 uint8_t dv_shift[2][22][64]; |
43 void (*idct_put[2])(UINT8 *dest, int line_size, DCTELEM *block); | 43 void (*idct_put[2])(uint8_t *dest, int line_size, DCTELEM *block); |
44 } DVVideoDecodeContext; | 44 } DVVideoDecodeContext; |
45 | 45 |
46 #include "dvdata.h" | 46 #include "dvdata.h" |
47 | 47 |
48 static VLC dv_vlc; | 48 static VLC dv_vlc; |
134 } | 134 } |
135 | 135 |
136 //#define VLC_DEBUG | 136 //#define VLC_DEBUG |
137 | 137 |
138 typedef struct BlockInfo { | 138 typedef struct BlockInfo { |
139 const UINT8 *shift_table; | 139 const uint8_t *shift_table; |
140 const UINT8 *scan_table; | 140 const uint8_t *scan_table; |
141 UINT8 pos; /* position in block */ | 141 uint8_t pos; /* position in block */ |
142 UINT8 eob_reached; /* true if EOB has been reached */ | 142 uint8_t eob_reached; /* true if EOB has been reached */ |
143 UINT8 dct_mode; | 143 uint8_t dct_mode; |
144 UINT8 partial_bit_count; | 144 uint8_t partial_bit_count; |
145 UINT16 partial_bit_buffer; | 145 uint16_t partial_bit_buffer; |
146 int shift_offset; | 146 int shift_offset; |
147 } BlockInfo; | 147 } BlockInfo; |
148 | 148 |
149 /* block size in bits */ | 149 /* block size in bits */ |
150 static const UINT16 block_sizes[6] = { | 150 static const uint16_t block_sizes[6] = { |
151 112, 112, 112, 112, 80, 80 | 151 112, 112, 112, 112, 80, 80 |
152 }; | 152 }; |
153 | 153 |
154 #ifndef ALT_BITSTREAM_READER | 154 #ifndef ALT_BITSTREAM_READER |
155 #error only works with ALT_BITSTREAM_READER | 155 #error only works with ALT_BITSTREAM_READER |
159 static void dv_decode_ac(DVVideoDecodeContext *s, | 159 static void dv_decode_ac(DVVideoDecodeContext *s, |
160 BlockInfo *mb, DCTELEM *block, int last_index) | 160 BlockInfo *mb, DCTELEM *block, int last_index) |
161 { | 161 { |
162 int last_re_index; | 162 int last_re_index; |
163 int shift_offset = mb->shift_offset; | 163 int shift_offset = mb->shift_offset; |
164 const UINT8 *scan_table = mb->scan_table; | 164 const uint8_t *scan_table = mb->scan_table; |
165 const UINT8 *shift_table = mb->shift_table; | 165 const uint8_t *shift_table = mb->shift_table; |
166 int pos = mb->pos; | 166 int pos = mb->pos; |
167 int level, pos1, sign, run; | 167 int level, pos1, sign, run; |
168 int partial_bit_count; | 168 int partial_bit_count; |
169 | 169 |
170 OPEN_READER(re, &s->gb); | 170 OPEN_READER(re, &s->gb); |
174 #endif | 174 #endif |
175 | 175 |
176 /* if we must parse a partial vlc, we do it here */ | 176 /* if we must parse a partial vlc, we do it here */ |
177 partial_bit_count = mb->partial_bit_count; | 177 partial_bit_count = mb->partial_bit_count; |
178 if (partial_bit_count > 0) { | 178 if (partial_bit_count > 0) { |
179 UINT8 buf[4]; | 179 uint8_t buf[4]; |
180 UINT32 v; | 180 uint32_t v; |
181 int l, l1; | 181 int l, l1; |
182 GetBitContext gb1; | 182 GetBitContext gb1; |
183 | 183 |
184 /* build the dummy bit buffer */ | 184 /* build the dummy bit buffer */ |
185 l = 16 - partial_bit_count; | 185 l = 16 - partial_bit_count; |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 /* mb_x and mb_y are in units of 8 pixels */ | 299 /* mb_x and mb_y are in units of 8 pixels */ |
300 static inline void dv_decode_video_segment(DVVideoDecodeContext *s, | 300 static inline void dv_decode_video_segment(DVVideoDecodeContext *s, |
301 UINT8 *buf_ptr1, | 301 uint8_t *buf_ptr1, |
302 const UINT16 *mb_pos_ptr) | 302 const uint16_t *mb_pos_ptr) |
303 { | 303 { |
304 int quant, dc, dct_mode, class1, j; | 304 int quant, dc, dct_mode, class1, j; |
305 int mb_index, mb_x, mb_y, v, last_index; | 305 int mb_index, mb_x, mb_y, v, last_index; |
306 DCTELEM *block, *block1; | 306 DCTELEM *block, *block1; |
307 int c_offset, bits_left; | 307 int c_offset, bits_left; |
308 UINT8 *y_ptr; | 308 uint8_t *y_ptr; |
309 BlockInfo mb_data[5 * 6], *mb, *mb1; | 309 BlockInfo mb_data[5 * 6], *mb, *mb1; |
310 void (*idct_put)(UINT8 *dest, int line_size, DCTELEM *block); | 310 void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); |
311 UINT8 *buf_ptr; | 311 uint8_t *buf_ptr; |
312 PutBitContext pb, vs_pb; | 312 PutBitContext pb, vs_pb; |
313 UINT8 mb_bit_buffer[80 + 4]; /* allow some slack */ | 313 uint8_t mb_bit_buffer[80 + 4]; /* allow some slack */ |
314 int mb_bit_count; | 314 int mb_bit_count; |
315 UINT8 vs_bit_buffer[5 * 80 + 4]; /* allow some slack */ | 315 uint8_t vs_bit_buffer[5 * 80 + 4]; /* allow some slack */ |
316 int vs_bit_count; | 316 int vs_bit_count; |
317 | 317 |
318 memset(s->block, 0, sizeof(s->block)); | 318 memset(s->block, 0, sizeof(s->block)); |
319 | 319 |
320 /* pass 1 : read DC and AC coefficients in blocks */ | 320 /* pass 1 : read DC and AC coefficients in blocks */ |
491 | 491 |
492 /* NOTE: exactly one frame must be given (120000 bytes for NTSC, | 492 /* NOTE: exactly one frame must be given (120000 bytes for NTSC, |
493 144000 bytes for PAL) */ | 493 144000 bytes for PAL) */ |
494 static int dvvideo_decode_frame(AVCodecContext *avctx, | 494 static int dvvideo_decode_frame(AVCodecContext *avctx, |
495 void *data, int *data_size, | 495 void *data, int *data_size, |
496 UINT8 *buf, int buf_size) | 496 uint8_t *buf, int buf_size) |
497 { | 497 { |
498 DVVideoDecodeContext *s = avctx->priv_data; | 498 DVVideoDecodeContext *s = avctx->priv_data; |
499 int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size; | 499 int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size; |
500 UINT8 *buf_ptr; | 500 uint8_t *buf_ptr; |
501 const UINT16 *mb_pos_ptr; | 501 const uint16_t *mb_pos_ptr; |
502 | 502 |
503 /* parse id */ | 503 /* parse id */ |
504 init_get_bits(&s->gb, buf, buf_size*8); | 504 init_get_bits(&s->gb, buf, buf_size*8); |
505 sct = get_bits(&s->gb, 3); | 505 sct = get_bits(&s->gb, 3); |
506 if (sct != 0) | 506 if (sct != 0) |
640 { | 640 { |
641 // DVAudioDecodeContext *s = avctx->priv_data; | 641 // DVAudioDecodeContext *s = avctx->priv_data; |
642 return 0; | 642 return 0; |
643 } | 643 } |
644 | 644 |
645 static UINT16 dv_audio_12to16(UINT16 sample) | 645 static uint16_t dv_audio_12to16(uint16_t sample) |
646 { | 646 { |
647 UINT16 shift, result; | 647 uint16_t shift, result; |
648 | 648 |
649 sample = (sample < 0x800) ? sample : sample | 0xf000; | 649 sample = (sample < 0x800) ? sample : sample | 0xf000; |
650 shift = (sample & 0xf00) >> 8; | 650 shift = (sample & 0xf00) >> 8; |
651 | 651 |
652 if (shift < 0x2 || shift > 0xd) { | 652 if (shift < 0x2 || shift > 0xd) { |
674 4. Audio is always returned as 16bit linear samples: 12bit | 674 4. Audio is always returned as 16bit linear samples: 12bit |
675 nonlinear samples are converted into 16bit linear ones. | 675 nonlinear samples are converted into 16bit linear ones. |
676 */ | 676 */ |
677 static int dvaudio_decode_frame(AVCodecContext *avctx, | 677 static int dvaudio_decode_frame(AVCodecContext *avctx, |
678 void *data, int *data_size, | 678 void *data, int *data_size, |
679 UINT8 *buf, int buf_size) | 679 uint8_t *buf, int buf_size) |
680 { | 680 { |
681 DVVideoDecodeContext *s = avctx->priv_data; | 681 DVVideoDecodeContext *s = avctx->priv_data; |
682 const UINT16 (*unshuffle)[9]; | 682 const uint16_t (*unshuffle)[9]; |
683 int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i; | 683 int smpls, freq, quant, sys, stride, difseg, ad, dp, nb_dif_segs, i; |
684 UINT16 lc, rc; | 684 uint16_t lc, rc; |
685 UINT8 *buf_ptr; | 685 uint8_t *buf_ptr; |
686 | 686 |
687 /* parse id */ | 687 /* parse id */ |
688 init_get_bits(&s->gb, &buf[AAUX_OFFSET], 5*8); | 688 init_get_bits(&s->gb, &buf[AAUX_OFFSET], 5*8); |
689 i = get_bits(&s->gb, 8); | 689 i = get_bits(&s->gb, 8); |
690 if (i != 0x50) { /* No audio ? */ | 690 if (i != 0x50) { /* No audio ? */ |
740 ((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1]; | 740 ((short *)data)[i] = (buf_ptr[dp] << 8) | buf_ptr[dp+1]; |
741 } else { /* 12bit quantization */ | 741 } else { /* 12bit quantization */ |
742 if (difseg >= nb_dif_segs/2) | 742 if (difseg >= nb_dif_segs/2) |
743 goto out; /* We're not doing 4ch at this time */ | 743 goto out; /* We're not doing 4ch at this time */ |
744 | 744 |
745 lc = ((UINT16)buf_ptr[dp] << 4) | | 745 lc = ((uint16_t)buf_ptr[dp] << 4) | |
746 ((UINT16)buf_ptr[dp+2] >> 4); | 746 ((uint16_t)buf_ptr[dp+2] >> 4); |
747 rc = ((UINT16)buf_ptr[dp+1] << 4) | | 747 rc = ((uint16_t)buf_ptr[dp+1] << 4) | |
748 ((UINT16)buf_ptr[dp+2] & 0x0f); | 748 ((uint16_t)buf_ptr[dp+2] & 0x0f); |
749 lc = dv_audio_12to16(lc); | 749 lc = dv_audio_12to16(lc); |
750 rc = dv_audio_12to16(rc); | 750 rc = dv_audio_12to16(rc); |
751 | 751 |
752 i = unshuffle[difseg][ad] + (dp - 8)/3 * stride; | 752 i = unshuffle[difseg][ad] + (dp - 8)/3 * stride; |
753 ((short *)data)[i] = lc; | 753 ((short *)data)[i] = lc; |