FFmpeg
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 
24 #include "libavutil/attributes.h"
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 
38 static 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);
60  align_put_bits(pb);
61  align_get_bits(gb);
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 */
align_put_bits
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Definition: put_bits.h:420
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:222
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
GetBitContext
Definition: get_bits.h:108
ff_pce_copy_bits
static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb, GetBitContext *gb, int bits)
Definition: mpeg4audio_copy_pce.h:29
bits
uint8_t bits
Definition: vp3data.h:128
ff_copy_pce_data
static int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
Definition: mpeg4audio_copy_pce.h:38
get_bits.h
PutBitContext
Definition: put_bits.h:50
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
attributes.h
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
av_always_inline
#define av_always_inline
Definition: attributes.h:49
align_get_bits
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:561
put_bits.h