comparison mpeg4audio.c @ 9636:8e95c7402d1a libavcodec

Subroutine to copy an AAC Program Config Element (PCE)
author alexc
date Wed, 13 May 2009 22:57:30 +0000
parents b687da895962
children 8649dc2299e2
comparison
equal deleted inserted replaced
9635:4d13e2e2503a 9636:8e95c7402d1a
1 /* 1 /*
2 * MPEG-4 Audio common code 2 * MPEG-4 Audio common code
3 * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr> 3 * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
4 * Copyright (c) 2009 Alex Converse <alex.converse@gmail.com>
4 * 5 *
5 * This file is part of FFmpeg. 6 * This file is part of FFmpeg.
6 * 7 *
7 * FFmpeg is free software; you can redistribute it and/or 8 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software 19 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 21 */
21 22
22 #include "get_bits.h" 23 #include "get_bits.h"
24 #include "put_bits.h"
23 #include "mpeg4audio.h" 25 #include "mpeg4audio.h"
24 26
25 const int ff_mpeg4audio_sample_rates[16] = { 27 const int ff_mpeg4audio_sample_rates[16] = {
26 96000, 88200, 64000, 48000, 44100, 32000, 28 96000, 88200, 64000, 48000, 44100, 32000,
27 24000, 22050, 16000, 12000, 11025, 8000, 7350 29 24000, 22050, 16000, 12000, 11025, 8000, 7350
82 get_bits1(&gb); // skip 1 bit 84 get_bits1(&gb); // skip 1 bit
83 } 85 }
84 } 86 }
85 return specific_config_bitindex; 87 return specific_config_bitindex;
86 } 88 }
89
90 static av_always_inline unsigned int copy_bits(PutBitContext *pb,
91 GetBitContext *gb,
92 int bits)
93 {
94 unsigned int el = get_bits(gb, bits);
95 put_bits(pb, bits, el);
96 return el;
97 }
98
99 int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
100 {
101 int five_bit_ch, four_bit_ch, comment_size, bits;
102 int offset = put_bits_count(pb);
103
104 copy_bits(pb, gb, 10); //Tag, Object Type, Frequency
105 five_bit_ch = copy_bits(pb, gb, 4); //Front
106 five_bit_ch += copy_bits(pb, gb, 4); //Side
107 five_bit_ch += copy_bits(pb, gb, 4); //Back
108 four_bit_ch = copy_bits(pb, gb, 2); //LFE
109 four_bit_ch += copy_bits(pb, gb, 3); //Data
110 five_bit_ch += copy_bits(pb, gb, 4); //Coupling
111 if (copy_bits(pb, gb, 1)) //Mono Mixdown
112 copy_bits(pb, gb, 4);
113 if (copy_bits(pb, gb, 1)) //Stereo Mixdown
114 copy_bits(pb, gb, 4);
115 if (copy_bits(pb, gb, 1)) //Matrix Mixdown
116 copy_bits(pb, gb, 3);
117 for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
118 copy_bits(pb, gb, 16);
119 if (bits)
120 copy_bits(pb, gb, bits);
121 align_put_bits(pb);
122 align_get_bits(gb);
123 comment_size = copy_bits(pb, gb, 8);
124 for (; comment_size > 0; comment_size--)
125 copy_bits(pb, gb, 8);
126
127 return put_bits_count(pb) - offset;
128 }