diff options
Diffstat (limited to 'libavcodec/cbs_mpeg2.c')
-rw-r--r-- | libavcodec/cbs_mpeg2.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/libavcodec/cbs_mpeg2.c b/libavcodec/cbs_mpeg2.c index 3db10c5..bfb64a0 100644 --- a/libavcodec/cbs_mpeg2.c +++ b/libavcodec/cbs_mpeg2.c @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -41,7 +41,7 @@ #define READ #define READWRITE read -#define RWContext BitstreamContext +#define RWContext GetBitContext #define xui(width, name, var) do { \ uint32_t value = 0; \ @@ -59,8 +59,8 @@ } while (0) #define nextbits(width, compare, var) \ - (bitstream_bits_left(rw) >= width && \ - (var = bitstream_peek(rw, width)) == (compare)) + (get_bits_left(rw) >= width && \ + (var = show_bits(rw, width)) == (compare)) #include "cbs_mpeg2_syntax_template.c" @@ -172,10 +172,10 @@ static int cbs_mpeg2_split_fragment(CodedBitstreamContext *ctx, static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { - BitstreamContext bc; + GetBitContext gbc; int err; - err = bitstream_init(&bc, unit->data, 8 * unit->data_size); + err = init_get_bits(&gbc, unit->data, 8 * unit->data_size); if (err < 0) return err; @@ -189,11 +189,11 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, return err; slice = unit->content; - err = cbs_mpeg2_read_slice_header(ctx, &bc, &slice->header); + err = cbs_mpeg2_read_slice_header(ctx, &gbc, &slice->header); if (err < 0) return err; - pos = bitstream_tell(&bc); + pos = get_bits_count(&gbc); len = unit->data_size; slice->data_size = len - pos / 8; @@ -220,7 +220,7 @@ static int cbs_mpeg2_read_unit(CodedBitstreamContext *ctx, if (err < 0) \ return err; \ header = unit->content; \ - err = cbs_mpeg2_read_ ## read_func(ctx, &bc, header); \ + err = cbs_mpeg2_read_ ## read_func(ctx, &gbc, header); \ if (err < 0) \ return err; \ } \ @@ -274,7 +274,7 @@ static int cbs_mpeg2_write_slice(CodedBitstreamContext *ctx, PutBitContext *pbc) { MPEG2RawSlice *slice = unit->content; - BitstreamContext bc; + GetBitContext gbc; size_t bits_left; int err; @@ -286,14 +286,14 @@ static int cbs_mpeg2_write_slice(CodedBitstreamContext *ctx, if (slice->data_size * 8 + 8 > put_bits_left(pbc)) return AVERROR(ENOSPC); - bitstream_init(&bc, slice->data, slice->data_size * 8); - bitstream_skip(&bc, slice->data_bit_start); + init_get_bits(&gbc, slice->data, slice->data_size * 8); + skip_bits_long(&gbc, slice->data_bit_start); - while (bitstream_bits_left(&bc) > 15) - put_bits(pbc, 16, bitstream_read(&bc, 16)); + while (get_bits_left(&gbc) > 15) + put_bits(pbc, 16, get_bits(&gbc, 16)); - bits_left = bitstream_bits_left(&bc); - put_bits(pbc, bits_left, bitstream_read(&bc, bits_left)); + bits_left = get_bits_left(&gbc); + put_bits(pbc, bits_left, get_bits(&gbc, bits_left)); // Align with zeroes. while (put_bits_count(pbc) % 8 != 0) @@ -319,7 +319,7 @@ static int cbs_mpeg2_write_unit(CodedBitstreamContext *ctx, if (err < 0) { av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a " "sufficiently large write buffer (last attempt " - "%zu bytes).\n", priv->write_buffer_size); + "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size); return err; } } @@ -369,7 +369,7 @@ static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, for (i = 0; i < frag->nb_units; i++) size += 3 + frag->units[i].data_size; - frag->data_ref = av_buffer_alloc(size); + frag->data_ref = av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!frag->data_ref) return AVERROR(ENOMEM); data = frag->data_ref->data; @@ -388,6 +388,7 @@ static int cbs_mpeg2_assemble_fragment(CodedBitstreamContext *ctx, av_assert0(dp == size); + memset(data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); frag->data = data; frag->data_size = size; |