Commit 91eb1b15 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (22 commits)
  prores: add FATE tests
  id3v2: reduce the scope of some non-globally-used symbols/structures
  id3v2: cosmetics: move some declarations before the places they are used
  shorten: remove the flush function.
  shn: do not allow seeking in the raw shn demuxer.
  avformat: add AVInputFormat flag AVFMT_NO_BYTE_SEEK.
  avformat: update AVInputFormat allowed flags
  avformat: don't unconditionally call ff_read_frame_flush() when trying to seek.
  truespeech: use sizeof() instead of hardcoded sizes
  truespeech: remove unneeded variable, 'consumed'
  truespeech: simplify truespeech_read_frame() by using get_bits()
  truespeech: decode directly to output buffer instead of a temp buffer
  truespeech: check to make sure channels == 1
  truespeech: check for large enough output buffer rather than truncating output
  truespeech: remove unneeded zero-size packet check.
  mlpdec: return meaningful error codes instead of -1
  mlpdec: remove unnecessary wrapper function
  mlpdec: only calculate output size once
  mlpdec: validate that the reported channel count matches the actual output channel count
  pcm: reduce pointer type casting
  ...

Conflicts:
	libavformat/avformat.h
	libavformat/id3v2.c
	libavformat/id3v2.h
	libavformat/utils.c
	libavformat/version.h
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 90705aab a62d3669
......@@ -13,6 +13,9 @@ libavutil: 2011-04-18
API changes, most recent first:
2011-xx-xx - xxxxxxx - lavf 53.9.0
Add AVFMT_NO_BYTE_SEEK AVInputFormat flag.
2011-10-12 - lavu 51.12.0
AVOptions API rewrite.
......
......@@ -116,7 +116,9 @@ static inline av_const int mid_pred(int a, int b, int c)
#ifndef sign_extend
static inline av_const int sign_extend(int val, unsigned bits)
{
return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
unsigned shift = 8 * sizeof(int) - bits;
union { unsigned u; int s; } v = { (unsigned) val << shift };
return v.s >> shift;
}
#endif
......
......@@ -138,11 +138,11 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
checksum = ff_mlp_checksum16(gb->buffer, 26);
if (checksum != AV_RL16(gb->buffer+26)) {
av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n");
return -1;
return AVERROR_INVALIDDATA;
}
if (get_bits_long(gb, 24) != 0xf8726f) /* Sync words */
return -1;
return AVERROR_INVALIDDATA;
mh->stream_type = get_bits(gb, 8);
......@@ -173,7 +173,7 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
mh->channels_thd_stream2 = get_bits(gb, 13);
} else
return -1;
return AVERROR_INVALIDDATA;
mh->access_unit_size = 40 << (ratebits & 7);
mh->access_unit_size_pow2 = 64 << (ratebits & 7);
......
This diff is collapsed.
......@@ -236,7 +236,7 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx)
/**
* Read PCM samples macro
* @param type Datatype of native machine format
* @param size Data size of native machine format
* @param endian bytestream_get_xxx() endian suffix
* @param src Source pointer (variable name)
* @param dst Destination pointer (variable name)
......@@ -244,13 +244,12 @@ static av_cold int pcm_decode_init(AVCodecContext * avctx)
* @param shift Bitshift (bits)
* @param offset Sample value offset
*/
#define DECODE(type, endian, src, dst, n, shift, offset) \
dst_##type = (type*)dst; \
#define DECODE(size, endian, src, dst, n, shift, offset) \
for(;n>0;n--) { \
register type v = bytestream_get_##endian(&src); \
*dst_##type++ = (v - offset) << shift; \
} \
dst = (short*)dst_##type;
uint##size##_t v = bytestream_get_##endian(&src); \
AV_WN##size##A(dst, (v - offset) << shift); \
dst += size / 8; \
}
static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
......@@ -260,14 +259,9 @@ static int pcm_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
PCMDecode *s = avctx->priv_data;
int sample_size, c, n, i;
short *samples;
uint8_t *samples;
const uint8_t *src, *src8, *src2[MAX_CHANNELS];
uint8_t *dstu8;
int16_t *dst_int16_t;
int32_t *dst_int32_t;
int64_t *dst_int64_t;
uint16_t *dst_uint16_t;
uint32_t *dst_uint32_t;
samples = data;
src = buf;
......@@ -314,29 +308,30 @@ static int pcm_decode_frame(AVCodecContext *avctx,
switch(avctx->codec->id) {
case CODEC_ID_PCM_U32LE:
DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000)
DECODE(32, le32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_U32BE:
DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000)
DECODE(32, be32, src, samples, n, 0, 0x80000000)
break;
case CODEC_ID_PCM_S24LE:
DECODE(int32_t, le24, src, samples, n, 8, 0)
DECODE(32, le24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_S24BE:
DECODE(int32_t, be24, src, samples, n, 8, 0)
DECODE(32, be24, src, samples, n, 8, 0)
break;
case CODEC_ID_PCM_U24LE:
DECODE(uint32_t, le24, src, samples, n, 8, 0x800000)
DECODE(32, le24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_U24BE:
DECODE(uint32_t, be24, src, samples, n, 8, 0x800000)
DECODE(32, be24, src, samples, n, 8, 0x800000)
break;
case CODEC_ID_PCM_S24DAUD:
for(;n>0;n--) {
uint32_t v = bytestream_get_be24(&src);
v >>= 4; // sync flags are here
*samples++ = av_reverse[(v >> 8) & 0xff] +
(av_reverse[v & 0xff] << 8);
AV_WN16A(samples, av_reverse[(v >> 8) & 0xff] +
(av_reverse[v & 0xff] << 8));
samples += 2;
}
break;
case CODEC_ID_PCM_S16LE_PLANAR:
......@@ -344,33 +339,33 @@ static int pcm_decode_frame(AVCodecContext *avctx,
for(c=0;c<avctx->channels;c++)
src2[c] = &src[c*n*2];
for(;n>0;n--)
for(c=0;c<avctx->channels;c++)
*samples++ = bytestream_get_le16(&src2[c]);
for(c=0;c<avctx->channels;c++) {
AV_WN16A(samples, bytestream_get_le16(&src2[c]));
samples += 2;
}
src = src2[avctx->channels-1];
break;
case CODEC_ID_PCM_U16LE:
DECODE(uint16_t, le16, src, samples, n, 0, 0x8000)
DECODE(16, le16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_U16BE:
DECODE(uint16_t, be16, src, samples, n, 0, 0x8000)
DECODE(16, be16, src, samples, n, 0, 0x8000)
break;
case CODEC_ID_PCM_S8:
dstu8= (uint8_t*)samples;
for(;n>0;n--) {
*dstu8++ = *src++ + 128;
*samples++ = *src++ + 128;
}
samples= (short*)dstu8;
break;
#if HAVE_BIGENDIAN
case CODEC_ID_PCM_F64LE:
DECODE(int64_t, le64, src, samples, n, 0, 0)
DECODE(64, le64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_F32LE:
DECODE(int32_t, le32, src, samples, n, 0, 0)
DECODE(32, le32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16LE:
DECODE(int16_t, le16, src, samples, n, 0, 0)
DECODE(16, le16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_F32BE:
......@@ -378,14 +373,14 @@ static int pcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_PCM_S16BE:
#else
case CODEC_ID_PCM_F64BE:
DECODE(int64_t, be64, src, samples, n, 0, 0)
DECODE(64, be64, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_S32BE:
DECODE(int32_t, be32, src, samples, n, 0, 0)
DECODE(32, be32, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_S16BE:
DECODE(int16_t, be16, src, samples, n, 0, 0)
DECODE(16, be16, src, samples, n, 0, 0)
break;
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F32LE:
......@@ -395,20 +390,22 @@ static int pcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_PCM_U8:
memcpy(samples, src, n*sample_size);
src += n*sample_size;
samples = (short*)((uint8_t*)data + n*sample_size);
samples += n * sample_size;
break;
case CODEC_ID_PCM_ZORK:
for(;n>0;n--) {
int x= *src++;
if(x&128) x-= 128;
else x = -x;
*samples++ = x << 8;
AV_WN16A(samples, x << 8);
samples += 2;
}
break;
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
for(;n>0;n--) {
*samples++ = s->table[*src++];
AV_WN16A(samples, s->table[*src++]);
samples += 2;
}
break;
case CODEC_ID_PCM_DVD:
......@@ -443,7 +440,7 @@ static int pcm_decode_frame(AVCodecContext *avctx,
avctx->bits_per_coded_sample);
return -1;
}
samples = (short *) dst_int32_t;
samples = (uint8_t *) dst_int32_t;
break;
case CODEC_ID_PCM_LXF:
dst_int32_t = data;
......@@ -463,12 +460,12 @@ static int pcm_decode_frame(AVCodecContext *avctx,
}
}
src += n * avctx->channels * 5;
samples = (short *) dst_int32_t;
samples = (uint8_t *) dst_int32_t;
break;
default:
return -1;
}
*data_size = (uint8_t *)samples - (uint8_t *)data;
*data_size = samples - (uint8_t *)data;
return src - buf;
}
......
......@@ -534,13 +534,6 @@ static av_cold int shorten_decode_close(AVCodecContext *avctx)
return 0;
}
static void shorten_flush(AVCodecContext *avctx){
ShortenContext *s = avctx->priv_data;
s->bitstream_size=
s->bitstream_index= 0;
}
AVCodec ff_shorten_decoder = {
.name = "shorten",
.type = AVMEDIA_TYPE_AUDIO,
......@@ -549,6 +542,5 @@ AVCodec ff_shorten_decoder = {
.init = shorten_decode_init,
.close = shorten_decode_close,
.decode = shorten_decode_frame,
.flush= shorten_flush,
.long_name= NULL_IF_CONFIG_SMALL("Shorten"),
};
......@@ -21,6 +21,8 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "dsputil.h"
#include "get_bits.h"
#include "truespeech_data.h"
/**
......@@ -32,7 +34,9 @@
* TrueSpeech decoder context
*/
typedef struct {
DSPContext dsp;
/* input data */
uint8_t buffer[32];
int16_t vector[8]; ///< input vector: 5/5/4/4/4/3/3/3
int offset1[2]; ///< 8-bit value, used in one copying offset
int offset2[4]; ///< 7-bit value, encodes offsets for copying and for two-point filter
......@@ -54,100 +58,66 @@ typedef struct {
static av_cold int truespeech_decode_init(AVCodecContext * avctx)
{
// TSContext *c = avctx->priv_data;
TSContext *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log_ask_for_sample(avctx, "Unsupported channel count: %d\n", avctx->channels);
return AVERROR(EINVAL);
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
dsputil_init(&c->dsp, avctx);
return 0;
}
static void truespeech_read_frame(TSContext *dec, const uint8_t *input)
{
uint32_t t;
/* first dword */
t = AV_RL32(input);
input += 4;
dec->flag = t & 1;
dec->vector[0] = ts_codebook[0][(t >> 1) & 0x1F];
dec->vector[1] = ts_codebook[1][(t >> 6) & 0x1F];
dec->vector[2] = ts_codebook[2][(t >> 11) & 0xF];
dec->vector[3] = ts_codebook[3][(t >> 15) & 0xF];
dec->vector[4] = ts_codebook[4][(t >> 19) & 0xF];
dec->vector[5] = ts_codebook[5][(t >> 23) & 0x7];
dec->vector[6] = ts_codebook[6][(t >> 26) & 0x7];
dec->vector[7] = ts_codebook[7][(t >> 29) & 0x7];
/* second dword */
t = AV_RL32(input);
input += 4;
dec->offset2[0] = (t >> 0) & 0x7F;
dec->offset2[1] = (t >> 7) & 0x7F;
dec->offset2[2] = (t >> 14) & 0x7F;
dec->offset2[3] = (t >> 21) & 0x7F;
dec->offset1[0] = ((t >> 28) & 0xF) << 4;
/* third dword */
t = AV_RL32(input);
input += 4;
dec->pulseval[0] = (t >> 0) & 0x3FFF;
dec->pulseval[1] = (t >> 14) & 0x3FFF;
dec->offset1[1] = (t >> 28) & 0x0F;
/* fourth dword */
t = AV_RL32(input);
input += 4;
dec->pulseval[2] = (t >> 0) & 0x3FFF;
dec->pulseval[3] = (t >> 14) & 0x3FFF;
dec->offset1[1] |= ((t >> 28) & 0x0F) << 4;
/* fifth dword */
t = AV_RL32(input);
input += 4;
dec->pulsepos[0] = (t >> 4) & 0x7FFFFFF;
dec->pulseoff[0] = (t >> 0) & 0xF;
dec->offset1[0] |= (t >> 31) & 1;
/* sixth dword */
t = AV_RL32(input);
input += 4;
dec->pulsepos[1] = (t >> 4) & 0x7FFFFFF;
dec->pulseoff[1] = (t >> 0) & 0xF;
dec->offset1[0] |= ((t >> 31) & 1) << 1;
/* seventh dword */
t = AV_RL32(input);
input += 4;
dec->pulsepos[2] = (t >> 4) & 0x7FFFFFF;
dec->pulseoff[2] = (t >> 0) & 0xF;
dec->offset1[0] |= ((t >> 31) & 1) << 2;
/* eighth dword */
t = AV_RL32(input);
input += 4;
dec->pulsepos[3] = (t >> 4) & 0x7FFFFFF;
dec->pulseoff[3] = (t >> 0) & 0xF;
dec->offset1[0] |= ((t >> 31) & 1) << 3;
GetBitContext gb;
dec->dsp.bswap_buf((uint32_t *)dec->buffer, (const uint32_t *)input, 8);
init_get_bits(&gb, dec->buffer, 32 * 8);
dec->vector[7] = ts_codebook[7][get_bits(&gb, 3)];
dec->vector[6] = ts_codebook[6][get_bits(&gb, 3)];
dec->vector[5] = ts_codebook[5][get_bits(&gb, 3)];
dec->vector[4] = ts_codebook[4][get_bits(&gb, 4)];
dec->vector[3] = ts_codebook[3][get_bits(&gb, 4)];
dec->vector[2] = ts_codebook[2][get_bits(&gb, 4)];
dec->vector[1] = ts_codebook[1][get_bits(&gb, 5)];
dec->vector[0] = ts_codebook[0][get_bits(&gb, 5)];
dec->flag = get_bits1(&gb);
dec->offset1[0] = get_bits(&gb, 4) << 4;
dec->offset2[3] = get_bits(&gb, 7);
dec->offset2[2] = get_bits(&gb, 7);
dec->offset2[1] = get_bits(&gb, 7);
dec->offset2[0] = get_bits(&gb, 7);
dec->offset1[1] = get_bits(&gb, 4);
dec->pulseval[1] = get_bits(&gb, 14);
dec->pulseval[0] = get_bits(&gb, 14);
dec->offset1[1] |= get_bits(&gb, 4) << 4;
dec->pulseval[3] = get_bits(&gb, 14);
dec->pulseval[2] = get_bits(&gb, 14);
dec->offset1[0] |= get_bits1(&gb);
dec->pulsepos[0] = get_bits_long(&gb, 27);
dec->pulseoff[0] = get_bits(&gb, 4);
dec->offset1[0] |= get_bits1(&gb) << 1;
dec->pulsepos[1] = get_bits_long(&gb, 27);
dec->pulseoff[1] = get_bits(&gb, 4);
dec->offset1[0] |= get_bits1(&gb) << 2;
dec->pulsepos[2] = get_bits_long(&gb, 27);
dec->pulseoff[2] = get_bits(&gb, 4);
dec->offset1[0] |= get_bits1(&gb) << 3;
dec->pulsepos[3] = get_bits_long(&gb, 27);
dec->pulseoff[3] = get_bits(&gb, 4);
}
static void truespeech_correlate_filter(TSContext *dec)
......@@ -157,7 +127,7 @@ static void truespeech_correlate_filter(TSContext *dec)
for(i = 0; i < 8; i++){
if(i > 0){
memcpy(tmp, dec->cvector, i * 2);
memcpy(tmp, dec->cvector, i * sizeof(*tmp));
for(j = 0; j < i; j++)
dec->cvector[j] = ((tmp[i - j - 1] * dec->vector[i]) +
(dec->cvector[j] << 15) + 0x4000) >> 15;
......@@ -199,7 +169,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart)
t = dec->offset2[quart];
if(t == 127){
memset(dec->newvec, 0, 60 * 2);
memset(dec->newvec, 0, 60 * sizeof(*dec->newvec));
return;
}
for(i = 0; i < 146; i++)
......@@ -224,7 +194,7 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart)
int16_t *ptr2;
int coef;
memset(out, 0, 60 * 2);
memset(out, 0, 60 * sizeof(*out));
for(i = 0; i < 7; i++) {
t = dec->pulseval[quart] & 3;
dec->pulseval[quart] >>= 2;
......@@ -340,45 +310,45 @@ static int truespeech_decode_frame(AVCodecContext *avctx,
int i, j;
short *samples = data;
int consumed = 0;
int16_t out_buf[240];
int iterations;
int iterations, out_size;
if (!buf_size)
return 0;
iterations = buf_size / 32;
if (buf_size < 32) {
if (!iterations) {
av_log(avctx, AV_LOG_ERROR,
"Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size);
return -1;
}
iterations = FFMIN(buf_size / 32, *data_size / 480);
out_size = iterations * 240 * av_get_bytes_per_sample(avctx->sample_fmt);
if (*data_size < out_size) {
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
return AVERROR(EINVAL);
}
memset(samples, 0, out_size);
for(j = 0; j < iterations; j++) {
truespeech_read_frame(c, buf + consumed);
consumed += 32;
truespeech_read_frame(c, buf);
buf += 32;
truespeech_correlate_filter(c);
truespeech_filters_merge(c);
memset(out_buf, 0, 240 * 2);
for(i = 0; i < 4; i++) {
truespeech_apply_twopoint_filter(c, i);
truespeech_place_pulses(c, out_buf + i * 60, i);
truespeech_update_filters(c, out_buf + i * 60, i);
truespeech_synth(c, out_buf + i * 60, i);
truespeech_place_pulses (c, samples, i);
truespeech_update_filters(c, samples, i);
truespeech_synth (c, samples, i);
samples += 60;
}
truespeech_save_prevvec(c);
/* finally output decoded frame */
for(i = 0; i < 240; i++)
*samples++ = out_buf[i];
}
*data_size = consumed * 15;
*data_size = out_size;
return consumed;
return buf_size;
}
AVCodec ff_truespeech_decoder = {
......
......@@ -837,17 +837,18 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
goto parse_common_info;
}
v->field_mode = 0;
if (v->interlace) {
v->fcm = decode012(gb);
if (v->fcm) {
if (v->fcm == 2)
v->field_mode = 1;
else
v->field_mode = 0;
if (!v->warn_interlaced++)
av_log(v->s.avctx, AV_LOG_ERROR,
"Interlaced frames/fields support is incomplete\n");
}
} else {
v->fcm = 0;
}
if (v->field_mode) {
......
......@@ -274,9 +274,10 @@ typedef struct AVFormatParameters {
#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */
#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */
#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */
#define AVFMT_TS_NONSTRICT 0x8000 /**< Format does not require strictly
increasing timestamps, but they must
still be monotonic */
#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */
#define AVFMT_TS_NONSTRICT 0x8000000 /**< Format does not require strictly
increasing timestamps, but they must
still be monotonic */
typedef struct AVOutputFormat {
const char *name;
......@@ -411,7 +412,9 @@ typedef struct AVInputFormat {
int64_t *pos, int64_t pos_limit);
/**
* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER.
* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
* AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
* AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK.
*/
int flags;
......
......@@ -33,6 +33,66 @@
#include "libavutil/dict.h"
#include "avio_internal.h"
const AVMetadataConv ff_id3v2_34_metadata_conv[] = {
{ "TALB", "album"},
{ "TCOM", "composer"},
{ "TCON", "genre"},
{ "TCOP", "copyright"},
{ "TENC", "encoded_by"},
{ "TIT2", "title"},
{ "TLAN", "language"},
{ "TPE1", "artist"},
{ "TPE2", "album_artist"},
{ "TPE3", "performer"},
{ "TPOS", "disc"},
{ "TPUB", "publisher"},
{ "TRCK", "track"},
{ "TSSE", "encoder"},
{ 0 }
};
const AVMetadataConv ff_id3v2_4_metadata_conv[] = {
{ "TDRL", "date"},
{ "TDRC", "date"},
{ "TDEN", "creation_time"},
{ "TSOA", "album-sort"},
{ "TSOP", "artist-sort"},
{ "TSOT", "title-sort"},
{ 0 }
};
static const AVMetadataConv id3v2_2_metadata_conv[] = {
{ "TAL", "album"},
{ "TCO", "genre"},
{ "TT2", "title"},
{ "TEN", "encoded_by"},
{ "TP1", "artist"},
{ "TP2", "album_artist"},
{ "TP3", "performer"},
{ "TRK", "track"},
{ 0 }
};
const char ff_id3v2_tags[][4] = {
"TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT",
"TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED",
"TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3",
"TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE",
{ 0 },
};
const char ff_id3v2_4_tags[][4] = {
"TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO",
"TPRO", "TSOA", "TSOP", "TSOT", "TSST",
{ 0 },
};
const char ff_id3v2_3_tags[][4] = {
"TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER",
{ 0 },
};
int ff_id3v2_match(const uint8_t *buf, const char * magic)
{
return buf[0] == magic[0] &&
......@@ -328,6 +388,18 @@ finish:
av_dict_set(m, "date", date, 0);
}
typedef struct ID3v2EMFunc {
const char *tag3;
const char *tag4;
void (*read)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta **);
void (*free)(void *);
} ID3v2EMFunc;
static const ID3v2EMFunc id3v2_extra_meta_funcs[] = {
{ "GEO", "GEOB", read_geobtag, free_geobtag },
{ NULL }
};
/**
* Get the corresponding ID3v2EMFunc struct for a tag.
* @param isv34 Determines if v2.2 or v2.3/4 strings are used
......@@ -336,16 +408,15 @@ finish:
static const ID3v2EMFunc *get_extra_meta_func(const char *tag, int isv34)
{
int i = 0;
while (ff_id3v2_extra_meta_funcs[i].tag3) {
while (id3v2_extra_meta_funcs[i].tag3) {
if (!memcmp(tag,
(isv34 ?
ff_id3v2_extra_meta_funcs[i].tag4 :
ff_id3v2_extra_meta_funcs[i].tag3),
(isv34 ? id3v2_extra_meta_funcs[i].tag4 :
id3v2_extra_meta_funcs[i].tag3),
(isv34 ? 4 : 3)))
return &ff_id3v2_extra_meta_funcs[i];
return &id3v2_extra_meta_funcs[i];
i++;
}
return &ff_id3v2_extra_meta_funcs[i];
return &id3v2_extra_meta_funcs[i];
}
static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags, ID3v2ExtraMeta **extra_meta)
......@@ -508,7 +579,7 @@ void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **e
}
} while (found_header);
ff_metadata_conv(&s->metadata, NULL, ff_id3v2_34_metadata_conv);
ff_metadata_conv(&s->metadata, NULL, ff_id3v2_2_metadata_conv);
ff_metadata_conv(&s->metadata, NULL, id3v2_2_metadata_conv);
ff_metadata_conv(&s->metadata, NULL, ff_id3v2_4_metadata_conv);
merge_date(&s->metadata);
}
......@@ -531,68 +602,3 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
current = next;
}
}
const ID3v2EMFunc ff_id3v2_extra_meta_funcs[] = {
{ "GEO", "GEOB", read_geobtag, free_geobtag },
{ NULL, NULL, NULL, NULL }
};
const AVMetadataConv ff_id3v2_34_metadata_conv[] = {
{ "TALB", "album"},
{ "TCOM", "composer"},
{ "TCON", "genre"},
{ "TCOP", "copyright"},
{ "TENC", "encoded_by"},
{ "TIT2", "title"},
{ "TLAN", "language"},
{ "TPE1", "artist"},
{ "TPE2", "album_artist"},
{ "TPE3", "performer"},
{ "TPOS", "disc"},
{ "TPUB", "publisher"},
{ "TRCK", "track"},
{ "TSSE", "encoder"},
{ 0 }
};
const AVMetadataConv ff_id3v2_4_metadata_conv[] = {
{ "TDRL", "date"},
{ "TDRC", "date"},
{ "TDEN", "creation_time"},
{ "TSOA", "album-sort"},
{ "TSOP", "artist-sort"},
{ "TSOT", "title-sort"},
{ 0 }
};
const AVMetadataConv ff_id3v2_2_metadata_conv[] = {
{ "TAL", "album"},
{ "TCO", "genre"},
{ "TT2", "title"},
{ "TEN", "encoded_by"},
{ "TP1", "artist"},
{ "TP2", "album_artist"},
{ "TP3", "performer"},
{ "TRK", "track"},
{ 0 }
};
const char ff_id3v2_tags[][4] = {
"TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT",
"TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED",
"TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3",
"TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE",
{ 0 },
};
const char ff_id3v2_4_tags[][4] = {
"TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO",
"TPRO", "TSOA", "TSOP", "TSOT", "TSST",
{ 0 },
};
const char ff_id3v2_3_tags[][4] = {
"TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER",
{ 0 },
};
......@@ -59,13 +59,6 @@ typedef struct ID3v2ExtraMetaGEOB {
uint8_t *data;
} ID3v2ExtraMetaGEOB;
typedef struct ID3v2EMFunc {
const char *tag3;
const char *tag4;
void (*read)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta **);
void (*free)(void *);
} ID3v2EMFunc;
/**
* Detect ID3v2 Header.
* @param buf must be ID3v2_HEADER_SIZE byte long
......@@ -99,11 +92,8 @@ void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **e
*/
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta);
extern const ID3v2EMFunc ff_id3v2_extra_meta_funcs[];
extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
extern const AVMetadataConv ff_id3v2_2_metadata_conv[];
/**
* A list of text information frames allowed in both ID3 v2.3 and v2.4
......
......@@ -245,7 +245,7 @@ AVInputFormat ff_shorten_demuxer = {
.long_name = NULL_IF_CONFIG_SMALL("raw Shorten"),
.read_header = ff_raw_audio_read_header,
.read_packet = ff_raw_read_partial_packet,
.flags= AVFMT_GENERIC_INDEX,
.flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK,
.extensions = "shn",
.value = CODEC_ID_SHORTEN,
};
......
......@@ -1808,10 +1808,12 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
int ret;
AVStream *st;
ff_read_frame_flush(s);
if(flags & AVSEEK_FLAG_BYTE)
if (flags & AVSEEK_FLAG_BYTE) {
if (s->iformat->flags & AVFMT_NO_BYTE_SEEK)
return -1;
ff_read_frame_flush(s);
return seek_frame_byte(s, stream_index, timestamp, flags);
}
if(stream_index < 0){
stream_index= av_find_default_stream_index(s);
......@@ -1825,19 +1827,23 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
/* first, we try the format specific seek */
AV_NOWARN_DEPRECATED(
if (s->iformat->read_seek)
if (s->iformat->read_seek) {
ff_read_frame_flush(s);
ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
else
} else
ret = -1;
)
if (ret >= 0) {
return 0;
}
if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH))
if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) {
ff_read_frame_flush(s);
return av_seek_frame_binary(s, stream_index, timestamp, flags);
else if (!(s->iformat->flags & AVFMT_NOGENSEARCH))
} else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) {
ff_read_frame_flush(s);
return seek_frame_generic(s, stream_index, timestamp, flags);
}
else
return -1;
}
......@@ -1847,10 +1853,10 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int
if(min_ts > ts || max_ts < ts)
return -1;
ff_read_frame_flush(s);
if (s->iformat->read_seek2)
if (s->iformat->read_seek2) {
ff_read_frame_flush(s);
return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
}
if(s->iformat->read_timestamp){
//try to seek via read_timestamp()
......
......@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 15
#define LIBAVFORMAT_VERSION_MINOR 16
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
......@@ -40,6 +40,7 @@ include $(SRC_PATH)/tests/fate/fft.mak
include $(SRC_PATH)/tests/fate/h264.mak
include $(SRC_PATH)/tests/fate/libavutil.mak
include $(SRC_PATH)/tests/fate/mp3.mak
#include $(SRC_PATH)/tests/fate/prores.mak
include $(SRC_PATH)/tests/fate/vorbis.mak
include $(SRC_PATH)/tests/fate/vp8.mak
......
FATE_PRORES = fate-prores-422 \
fate-prores-422_hq \
fate-prores-422_lt \
fate-prores-422_proxy \
fate-prores-alpha \
FATE_TESTS += $(FATE_PRORES)
fate-prores: $(FATE_PRORES)
fate-prores-422: CMD = framecrc -vsync 0 -i $(SAMPLES)/prores/Sequence_1-Apple_ProRes_422.mov
fate-prores-422_hq: CMD = framecrc -vsync 0 -i $(SAMPLES)/prores/Sequence_1-Apple_ProRes_422_HQ.mov
fate-prores-422_lt: CMD = framecrc -vsync 0 -i $(SAMPLES)/prores/Sequence_1-Apple_ProRes_422_LT.mov
fate-prores-422_proxy: CMD = framecrc -vsync 0 -i $(SAMPLES)/prores/Sequence_1-Apple_ProRes_422_Proxy.mov
fate-prores-alpha: CMD = framecrc -vsync 0 -i $(SAMPLES)/prores/Sequence_1-Apple_ProRes_with_Alpha.mov
0, 0, 8294400, 0xe8e9d448
0, 3003, 8294400, 0xe8e9d448
0, 0, 8294400, 0x817063b0
0, 3003, 8294400, 0x817063b0
0, 0, 8294400, 0xcd4ccde1
0, 3003, 8294400, 0xcd4ccde1
0, 0, 8294400, 0x51d29320
0, 3003, 8294400, 0x51d29320
0, 0, 8294400, 0xee48d74b
0, 3003, 8294400, 0x2a0c7eb1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment