FFmpeg
Loading...
Searching...
No Matches
mpeg4audio_copy_pce.h
Go to the documentation of this file.
1/*
2 * MPEG-4 Audio PCE copying function
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_MPEG4AUDIO_COPY_PCE_H
22#define AVCODEC_MPEG4AUDIO_COPY_PCE_H
23
25
26#include "get_bits.h"
27#include "put_bits.h"
28
30 GetBitContext *gb,
31 int bits)
32{
33 unsigned int el = get_bits(gb, bits);
34 put_bits(pb, bits, el);
35 return el;
36}
37
38static inline int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
39{
40 int five_bit_ch, four_bit_ch, comment_size, bits;
41 int offset = put_bits_count(pb);
42
43 ff_pce_copy_bits(pb, gb, 10); // Tag, Object Type, Frequency
44 five_bit_ch = ff_pce_copy_bits(pb, gb, 4); // Front
45 five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Side
46 five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Back
47 four_bit_ch = ff_pce_copy_bits(pb, gb, 2); // LFE
48 four_bit_ch += ff_pce_copy_bits(pb, gb, 3); // Data
49 five_bit_ch += ff_pce_copy_bits(pb, gb, 4); // Coupling
50 if (ff_pce_copy_bits(pb, gb, 1)) // Mono Mixdown
51 ff_pce_copy_bits(pb, gb, 4);
52 if (ff_pce_copy_bits(pb, gb, 1)) // Stereo Mixdown
53 ff_pce_copy_bits(pb, gb, 4);
54 if (ff_pce_copy_bits(pb, gb, 1)) // Matrix Mixdown
55 ff_pce_copy_bits(pb, gb, 3);
56 for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
57 ff_pce_copy_bits(pb, gb, 16);
58 if (bits)
59 ff_pce_copy_bits(pb, gb, bits);
62 comment_size = ff_pce_copy_bits(pb, gb, 8);
63 for (; comment_size > 0; comment_size--)
64 ff_pce_copy_bits(pb, gb, 8);
65
66 return put_bits_count(pb) - offset;
67}
68
69#endif /* AVCODEC_MPEG4AUDIO_COPY_PCE_H */
static const uint8_t bits[8]
Definition fastaudio.c:100
bitstream reader API header.
static const uint8_t * align_get_bits(GetBitContext *s)
Definition get_bits.h:560
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition j2kenc.c:154
unsigned offset
Definition libaomenc.c:763
Macro definitions for various function/variable attributes.
#define av_always_inline
Definition attributes.h:72
static int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb, GetBitContext *gb, int bits)
bitstream writer API
static int put_bits_count(PutBitContext *s)
Definition put_bits.h:90
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Definition put_bits.h:445