1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

mov: Convert to the new bitstream reader

This commit is contained in:
Alexandra Hájková 2016-04-16 12:17:24 +02:00 committed by Diego Biurrun
parent 44129e3804
commit a895292f27
2 changed files with 27 additions and 24 deletions

View File

@ -39,13 +39,15 @@
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavutil/spherical.h" #include "libavutil/spherical.h"
#include "libavutil/stereo3d.h" #include "libavutil/stereo3d.h"
#include "libavcodec/ac3tab.h" #include "libavcodec/ac3tab.h"
#include "libavcodec/bitstream.h"
#include "avformat.h" #include "avformat.h"
#include "internal.h" #include "internal.h"
#include "avio_internal.h" #include "avio_internal.h"
#include "riff.h" #include "riff.h"
#include "isom.h" #include "isom.h"
#include "libavcodec/get_bits.h"
#include "id3v1.h" #include "id3v1.h"
#include "mov_chan.h" #include "mov_chan.h"
#include "replaygain.h" #include "replaygain.h"
@ -2078,7 +2080,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVStream *st; AVStream *st;
MOVStreamContext *sc; MOVStreamContext *sc;
unsigned int i, entries, sample_size, field_size, num_bytes; unsigned int i, entries, sample_size, field_size, num_bytes;
GetBitContext gb; BitstreamContext bc;
unsigned char* buf; unsigned char* buf;
int ret; int ret;
@ -2136,10 +2138,10 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return ret; return ret;
} }
init_get_bits(&gb, buf, 8*num_bytes); bitstream_init(&bc, buf, 8 * num_bytes);
for (i = 0; i < entries && !pb->eof_reached; i++) { for (i = 0; i < entries && !pb->eof_reached; i++) {
sc->sample_sizes[i] = get_bits_long(&gb, field_size); sc->sample_sizes[i] = bitstream_read(&bc, field_size);
sc->data_size += sc->sample_sizes[i]; sc->data_size += sc->sample_sizes[i];
} }

View File

@ -31,7 +31,8 @@
#include "avio.h" #include "avio.h"
#include "isom.h" #include "isom.h"
#include "avc.h" #include "avc.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/bitstream.h"
#include "libavcodec/put_bits.h" #include "libavcodec/put_bits.h"
#include "libavcodec/vc1_common.h" #include "libavcodec/vc1_common.h"
#include "internal.h" #include "internal.h"
@ -240,7 +241,7 @@ static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
{ {
GetBitContext gbc; BitstreamContext bc;
PutBitContext pbc; PutBitContext pbc;
uint8_t buf[3]; uint8_t buf[3];
int fscod, bsid, bsmod, acmod, lfeon, frmsizecod; int fscod, bsid, bsmod, acmod, lfeon, frmsizecod;
@ -251,21 +252,21 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, 11); avio_wb32(pb, 11);
ffio_wfourcc(pb, "dac3"); ffio_wfourcc(pb, "dac3");
init_get_bits(&gbc, track->vos_data + 4, (track->vos_len - 4) * 8); bitstream_init(&bc, track->vos_data + 4, (track->vos_len - 4) * 8);
fscod = get_bits(&gbc, 2); fscod = bitstream_read(&bc, 2);
frmsizecod = get_bits(&gbc, 6); frmsizecod = bitstream_read(&bc, 6);
bsid = get_bits(&gbc, 5); bsid = bitstream_read(&bc, 5);
bsmod = get_bits(&gbc, 3); bsmod = bitstream_read(&bc, 3);
acmod = get_bits(&gbc, 3); acmod = bitstream_read(&bc, 3);
if (acmod == 2) { if (acmod == 2) {
skip_bits(&gbc, 2); // dsurmod bitstream_skip(&bc, 2); // dsurmod
} else { } else {
if ((acmod & 1) && acmod != 1) if ((acmod & 1) && acmod != 1)
skip_bits(&gbc, 2); // cmixlev bitstream_skip(&bc, 2); // cmixlev
if (acmod & 4) if (acmod & 4)
skip_bits(&gbc, 2); // surmixlev bitstream_skip(&bc, 2); // surmixlev
} }
lfeon = get_bits1(&gbc); lfeon = bitstream_read_bit(&bc);
init_put_bits(&pbc, buf, sizeof(buf)); init_put_bits(&pbc, buf, sizeof(buf));
put_bits(&pbc, 2, fscod); put_bits(&pbc, 2, fscod);
@ -462,28 +463,28 @@ static int mov_write_dvc1_structs(MOVTrack *track, uint8_t *buf)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
start = find_next_marker(track->vos_data, end); start = find_next_marker(track->vos_data, end);
for (next = start; next < end; start = next) { for (next = start; next < end; start = next) {
GetBitContext gb; BitstreamContext bc;
int size; int size;
next = find_next_marker(start + 4, end); next = find_next_marker(start + 4, end);
size = next - start - 4; size = next - start - 4;
if (size <= 0) if (size <= 0)
continue; continue;
unescaped_size = vc1_unescape_buffer(start + 4, size, unescaped); unescaped_size = vc1_unescape_buffer(start + 4, size, unescaped);
init_get_bits(&gb, unescaped, 8 * unescaped_size); bitstream_init(&bc, unescaped, 8 * unescaped_size);
if (AV_RB32(start) == VC1_CODE_SEQHDR) { if (AV_RB32(start) == VC1_CODE_SEQHDR) {
int profile = get_bits(&gb, 2); int profile = bitstream_read(&bc, 2);
if (profile != PROFILE_ADVANCED) { if (profile != PROFILE_ADVANCED) {
av_free(unescaped); av_free(unescaped);
return AVERROR(ENOSYS); return AVERROR(ENOSYS);
} }
seq_found = 1; seq_found = 1;
level = get_bits(&gb, 3); level = bitstream_read(&bc, 3);
/* chromaformat, frmrtq_postproc, bitrtq_postproc, postprocflag, /* chromaformat, frmrtq_postproc, bitrtq_postproc, postprocflag,
* width, height */ * width, height */
skip_bits_long(&gb, 2 + 3 + 5 + 1 + 2*12); bitstream_skip(&bc, 2 + 3 + 5 + 1 + 2 * 12);
skip_bits(&gb, 1); /* broadcast */ bitstream_skip(&bc, 1); /* broadcast */
interlace = get_bits1(&gb); interlace = bitstream_read_bit(&bc);
skip_bits(&gb, 4); /* tfcntrflag, finterpflag, reserved, psf */ bitstream_skip(&bc, 4); /* tfcntrflag, finterpflag, reserved, psf */
} }
} }
if (!seq_found) { if (!seq_found) {