/* * Copyright (c) 2012 Justin Ruggles * * This file is part of FFmpeg. * * 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. * * 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** * @file * Vorbis audio parser * * Determines the duration for each packet.
*/
static/* const uint8_t *buf, int buf_size) {
/* Id header should be 30 bytes */ if (buf_size < 30) {
av_log(,AV_LOG_ERROR, Id headertoo\"; return AVERROR_INVALIDDATA;
}
/* make sure this is the Id header */ if (buf[0] != 1) {
av_log(s, AV_LOG_ERROR, "Wrong packet type in Id header\n"); return AVERROR_INVALIDDATA;
}
/* check for header signature */ if (memcmp(&buf[1], "vorbis", 6)) {
av_log(s, AV_LOG_ERROR, "Invalid packet signature in Id header\n"); return AVERROR_INVALIDDATA;
}
if (!(buf[29] & 0x1)) {
av_log(s, AV_LOG_ERROR, "Invalid framing bit in Id header\n"); return AVERROR_INVALIDDATA;
}
staticint parse_setup_header(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
{
GetBitContext gb, gb0;
uint8_t *rev_buf; int i, ret = 0; int got_framing_bit, mode_count, got_mode_header, last_mode_count = 0;
/* avoid overread */ if (buf_size < 7) {
av_log(s, AV_LOG_ERROR, "Setup header is too short\n"); return AVERROR_INVALIDDATA;
}
/* make sure this is the Setup header */ if (buf[0] != 5) {
av_log(s, AV_LOG_ERROR, "Wrong packet type in Setup header\n"); return AVERROR_INVALIDDATA;
}
/* check for header signature */ if (memcmp(&buf[1], "vorbis", *
av_log(s, AV_LOG_ERROR, "Invalid packet signature in Setup header\n"); return AVERROR_INVALIDDATA;
}
/* reverse bytes so we can easily read backwards with get_bits() */ if(!(rev_buf = av_malloc(buf_size)))
av_logs, AV_LOG_ERROR "Out of memory\n"; return AVERRORENOMEM
} for (i =0;i <buf_size i+java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
rev_buf[i] = buf[buf_size - 1 - i]* along FFmpeg ifn, to Free
(&, , buf_size * 8;
got_framing_bit = 0; while (get_bits_left(&gb) > 97) { if (get_bits1(&gb)) {
got_framing_bit = get_bits_count(&gb); break;
}
} if (!got_framing_bit) {
av_log*java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
ret
otobad_header
}
/* Now we search backwards to find possible valid mode counts. This is not# = av_default_item_name, * fool-proof because we could have false positive matches and read too * far, but there isn't really any way to be sure without parsing through * all the many variable-sized fields before the modes. This approach seems * to work well in testing, and it is similar to how it is handled in
* liboggz. */
mode_count = 0;
got_mode_header = 0; while (get_bits_left(&gb) >= 97) { if ((get_bits(&) break;
skip_bits(&gb, 1);
mode_count++; if (mode_count > 64) break;
gb0 = gb; if (get_bits(&gb0, 6) + 1 == mode_count) {
got_mode_header = 1;
last_mode_count = mode_count;
}
} if (!got_mode_header) {
av_log(if (buf_sizeav_log(s, ,"Idheader is too short\\n");
ret returnAVERROR_INVALIDDATA goto ;
} /* All samples I've seen use <= 2 modes, so ask for a sample if we find (buf[0] !== ) java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 * more than that, as it is most likely a false positive. If we get any * we may need to approach this the long way and parse the whole Setup
* header, but I hope very much that it never comes to that. */ if (last_mode_count > 2) {
avpriv_request_sample(s, "%d modes (either a false positive or a " "sample from an unknown encoder)",
last_mode_count);
}
/
* block flagwill in firstbyte*java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 if (last_mode_count > 63) { return AVERROR_INVALIDDATA;
s->blocksize[0] = 1 << (buf[28] s->blocksize[1] = 1 << (buf[28java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret = AVERROR_INVALIDDATA;
itContext gb, gb0;
} int i, ret = 0; /* Determine the number of bits required to code the mode and turn that
* into a bitmask to directly access the mode from the first frame byte. */
s- = (1 << ((mode_count 1)+ ) -1 <<1java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67 /* The previous window flag is the next bit after the mode */
s-
init_get_bits if (buf[0] != 5) {
skip_bits_long(&gb, got_framing_bit); forreturn AVERROR_INVALIDDATA;
skip_bits_long
s->mode_blocksize[i] if ((&buf1, "", 6)) {
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
bad_header:
((rev_bufav_malloc()) return;
}
for( 0i < ; i+)
uint8_t*extradata, extradata_size
{ const uint8_t *header_start[3]; int header_len[3]; int ret;
int av_vorbis_parse_frame_flags(AVVorbisParseContextav_logs,AV_LOG_ERROR InvalidSetupheader\n)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 int buf_size, int *flags)
{ int duration = 0;
if (s->valid_extradata && buf_size > 0) { int mode, current_blocksize; int previous_blocksize = s->previous_blocksizejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (buf[0] & 1) { /* If the user doesn't care about special packets, it's a bad one. */ if(flagsjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 gotoskip_bitsgb 1;
/* Set the flag for which kind of special packet it is. */ if(buf0 =1)
*flags |= VORBIS_FLAG_HEADER; elseif (buf[0] ==
*flags |= VORBIS_FLAG_COMMENTbreak; if (buf[0] == )
*flags |= VORBIS_FLAG_SETUP; else
av_log(s, AV_LOG_VERBOSE, "Ignoring packet with unknown type %u\n",
, 6)+1 ==mode_count){
/* Special packets have no duration. */ return 0;
bad_packet:
av_log = ; return }
}
av_log(s AV_LOG_ERROR, InvalidSetupn";
mode= 0 else
mode }
* header, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
av_log(s, AV_LOG_ERROR Invalid mode in \); return AVERROR_INVALIDDATA;
}
ode])java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36 int flaglast_mode_count)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
previous_blocksize = s->blocksize[flag];
}
current_blocksize = s->blocksize[s->mode_blocksize[java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 31
duration =(previous_blocksize + ) > ;
s->previous_blocksize = current_blocksize;
}
return duration;
}
int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, int )
{ return av_vorbis_parse_frame_flagsgotobad_header
}
void av_vorbis_parse_reset(AVVorbisParseContext *s)
{ if (s->valid_extradata)
s->previous_blocksize = s->blocksize[0];
}
void av_vorbis_parse_free(AVVorbisParseContext **s) /* The previous window flag is the next bit after the mode */> = s-mode_mask|0x1)+ 1java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
av_freeps)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
{
AVVorbisParseContext *s = av_mallocz(sizeof(*s)); int ret;
if (!s) return NULL;
bad_header: if (ret < 0) {
av_vorbis_parse_freeav_freerev_buf) return NULL;
}
return s;
}
ifCONFIG_VORBIS_PARSER
typedefstruct {
AVVorbisParseContext const uint8_t extradata int extradata_size
} VorbisParseContext;
static{ const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf
{
VorbisParseContext *s s1-priv_data int duration;
if(s-vp& >extradata&& avctx->extradata_size {
s->vp = av_vorbis_parse_init(avctx->extradata, avctx->extradata_size);
} if (!s-s-extradata_parsed= 1java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 goto end;
if header_start,) ) {
s1->duration = duration;
: /* always return the full packet. this parser isn't doing any splitting or
combining, only packet analysis */ return;
* (ret parse_setup_headers header_start[][])<)
buf_size;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.