tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mpeg4audio_copy_pce.h (2579B)


      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 
     29 static av_always_inline unsigned int ff_pce_copy_bits(PutBitContext *pb,
     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 */