tak: reduce difference with qatar
Mostly cosmetics changes, but also makes decoding little faster here. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@ -56,12 +56,13 @@ static int tak_get_nb_samples(int sample_rate, enum TAKFrameSizeType type)
|
|||||||
|
|
||||||
if (type <= TAK_FST_250ms) {
|
if (type <= TAK_FST_250ms) {
|
||||||
nb_samples = sample_rate * frame_duration_type_quants[type] >>
|
nb_samples = sample_rate * frame_duration_type_quants[type] >>
|
||||||
TAK_FRAME_DURATION_QUANT_SHIFT;
|
TAK_FRAME_DURATION_QUANT_SHIFT;
|
||||||
max_nb_samples = 16384;
|
max_nb_samples = 16384;
|
||||||
} else if (type < FF_ARRAY_ELEMS(frame_duration_type_quants)) {
|
} else if (type < FF_ARRAY_ELEMS(frame_duration_type_quants)) {
|
||||||
nb_samples = frame_duration_type_quants[type];
|
nb_samples = frame_duration_type_quants[type];
|
||||||
max_nb_samples = sample_rate * frame_duration_type_quants[TAK_FST_250ms] >>
|
max_nb_samples = sample_rate *
|
||||||
TAK_FRAME_DURATION_QUANT_SHIFT;
|
frame_duration_type_quants[TAK_FST_250ms] >>
|
||||||
|
TAK_FRAME_DURATION_QUANT_SHIFT;
|
||||||
} else {
|
} else {
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@ -116,9 +117,12 @@ void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)
|
|||||||
s->samples = get_bits64(gb, TAK_SIZE_SAMPLES_NUM_BITS);
|
s->samples = get_bits64(gb, TAK_SIZE_SAMPLES_NUM_BITS);
|
||||||
|
|
||||||
s->data_type = get_bits(gb, TAK_FORMAT_DATA_TYPE_BITS);
|
s->data_type = get_bits(gb, TAK_FORMAT_DATA_TYPE_BITS);
|
||||||
s->sample_rate = get_bits(gb, TAK_FORMAT_SAMPLE_RATE_BITS) + TAK_SAMPLE_RATE_MIN;
|
s->sample_rate = get_bits(gb, TAK_FORMAT_SAMPLE_RATE_BITS) +
|
||||||
s->bps = get_bits(gb, TAK_FORMAT_BPS_BITS) + TAK_BPS_MIN;
|
TAK_SAMPLE_RATE_MIN;
|
||||||
s->channels = get_bits(gb, TAK_FORMAT_CHANNEL_BITS) + TAK_CHANNELS_MIN;
|
s->bps = get_bits(gb, TAK_FORMAT_BPS_BITS) +
|
||||||
|
TAK_BPS_MIN;
|
||||||
|
s->channels = get_bits(gb, TAK_FORMAT_CHANNEL_BITS) +
|
||||||
|
TAK_CHANNELS_MIN;
|
||||||
|
|
||||||
if (get_bits1(gb)) {
|
if (get_bits1(gb)) {
|
||||||
skip_bits(gb, TAK_FORMAT_VALID_BITS);
|
skip_bits(gb, TAK_FORMAT_VALID_BITS);
|
||||||
@ -136,31 +140,25 @@ void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s)
|
|||||||
s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
|
s->frame_samples = tak_get_nb_samples(s->sample_rate, frame_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FRAME_IS_LAST 1
|
|
||||||
#define FRAME_HAVE_INFO 2
|
|
||||||
#define FRAME_HAVE_METADATA 4
|
|
||||||
|
|
||||||
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
||||||
TAKStreamInfo *ti, int log_level_offset)
|
TAKStreamInfo *ti, int log_level_offset)
|
||||||
{
|
{
|
||||||
int flags;
|
|
||||||
|
|
||||||
if (get_bits(gb, TAK_FRAME_HEADER_SYNC_ID_BITS) != TAK_FRAME_HEADER_SYNC_ID) {
|
if (get_bits(gb, TAK_FRAME_HEADER_SYNC_ID_BITS) != TAK_FRAME_HEADER_SYNC_ID) {
|
||||||
av_log(avctx, AV_LOG_ERROR + log_level_offset, "missing sync id\n");
|
av_log(avctx, AV_LOG_ERROR + log_level_offset, "missing sync id\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = get_bits(gb, TAK_FRAME_HEADER_FLAGS_BITS);
|
ti->flags = get_bits(gb, TAK_FRAME_HEADER_FLAGS_BITS);
|
||||||
ti->frame_num = get_bits(gb, TAK_FRAME_HEADER_NO_BITS);
|
ti->frame_num = get_bits(gb, TAK_FRAME_HEADER_NO_BITS);
|
||||||
|
|
||||||
if (flags & FRAME_IS_LAST) {
|
if (ti->flags & TAK_FRAME_FLAG_IS_LAST) {
|
||||||
ti->last_frame_samples = get_bits(gb, TAK_FRAME_HEADER_SAMPLE_COUNT_BITS) + 1;
|
ti->last_frame_samples = get_bits(gb, TAK_FRAME_HEADER_SAMPLE_COUNT_BITS) + 1;
|
||||||
skip_bits(gb, 2);
|
skip_bits(gb, 2);
|
||||||
} else {
|
} else {
|
||||||
ti->last_frame_samples = 0;
|
ti->last_frame_samples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & FRAME_HAVE_INFO) {
|
if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {
|
||||||
avpriv_tak_parse_streaminfo(gb, ti);
|
avpriv_tak_parse_streaminfo(gb, ti);
|
||||||
|
|
||||||
if (get_bits(gb, 6))
|
if (get_bits(gb, 6))
|
||||||
@ -168,7 +166,7 @@ int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
|||||||
align_get_bits(gb);
|
align_get_bits(gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & FRAME_HAVE_METADATA)
|
if (ti->flags & TAK_FRAME_FLAG_HAS_METADATA)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
skip_bits(gb, 24);
|
skip_bits(gb, 24);
|
||||||
|
116
libavcodec/tak.h
116
libavcodec/tak.h
@ -33,64 +33,74 @@
|
|||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
|
||||||
#define TAK_FORMAT_DATA_TYPE_BITS 3
|
#define TAK_FORMAT_DATA_TYPE_BITS 3
|
||||||
#define TAK_FORMAT_SAMPLE_RATE_BITS 18
|
#define TAK_FORMAT_SAMPLE_RATE_BITS 18
|
||||||
#define TAK_FORMAT_BPS_BITS 5
|
#define TAK_FORMAT_BPS_BITS 5
|
||||||
#define TAK_FORMAT_CHANNEL_BITS 4
|
#define TAK_FORMAT_CHANNEL_BITS 4
|
||||||
#define TAK_FORMAT_VALID_BITS 5
|
#define TAK_FORMAT_VALID_BITS 5
|
||||||
#define TAK_FORMAT_CH_LAYOUT_BITS 6
|
#define TAK_FORMAT_CH_LAYOUT_BITS 6
|
||||||
#define TAK_SIZE_FRAME_DURATION_BITS 4
|
#define TAK_SIZE_FRAME_DURATION_BITS 4
|
||||||
#define TAK_SIZE_SAMPLES_NUM_BITS 35
|
#define TAK_SIZE_SAMPLES_NUM_BITS 35
|
||||||
#define TAK_LAST_FRAME_POS_BITS 40
|
#define TAK_LAST_FRAME_POS_BITS 40
|
||||||
#define TAK_LAST_FRAME_SIZE_BITS 24
|
#define TAK_LAST_FRAME_SIZE_BITS 24
|
||||||
#define TAK_ENCODER_CODEC_BITS 6
|
#define TAK_ENCODER_CODEC_BITS 6
|
||||||
#define TAK_ENCODER_PROFILE_BITS 4
|
#define TAK_ENCODER_PROFILE_BITS 4
|
||||||
#define TAK_ENCODER_VERSION_BITS 24
|
#define TAK_ENCODER_VERSION_BITS 24
|
||||||
#define TAK_SAMPLE_RATE_MIN 6000
|
#define TAK_SAMPLE_RATE_MIN 6000
|
||||||
#define TAK_CHANNELS_MIN 1
|
#define TAK_CHANNELS_MIN 1
|
||||||
#define TAK_BPS_MIN 8
|
#define TAK_BPS_MIN 8
|
||||||
#define TAK_FRAME_HEADER_FLAGS_BITS 3
|
#define TAK_FRAME_HEADER_FLAGS_BITS 3
|
||||||
#define TAK_FRAME_HEADER_SYNC_ID 0xA0FF
|
#define TAK_FRAME_HEADER_SYNC_ID 0xA0FF
|
||||||
#define TAK_FRAME_HEADER_SYNC_ID_BITS 16
|
#define TAK_FRAME_HEADER_SYNC_ID_BITS 16
|
||||||
#define TAK_FRAME_HEADER_SAMPLE_COUNT_BITS 14
|
#define TAK_FRAME_HEADER_SAMPLE_COUNT_BITS 14
|
||||||
#define TAK_FRAME_HEADER_NO_BITS 21
|
#define TAK_FRAME_HEADER_NO_BITS 21
|
||||||
#define TAK_FRAME_DURATION_QUANT_SHIFT 5
|
#define TAK_FRAME_DURATION_QUANT_SHIFT 5
|
||||||
#define TAK_CRC24_BITS 24
|
#define TAK_CRC24_BITS 24
|
||||||
|
|
||||||
#define TAK_MAX_CHANNELS ( 1 << TAK_FORMAT_CHANNEL_BITS )
|
|
||||||
|
|
||||||
#define TAK_MIN_FRAME_HEADER_BITS ( TAK_FRAME_HEADER_SYNC_ID_BITS + \
|
#define TAK_FRAME_FLAG_IS_LAST 0x1
|
||||||
TAK_FRAME_HEADER_FLAGS_BITS + \
|
#define TAK_FRAME_FLAG_HAS_INFO 0x2
|
||||||
TAK_FRAME_HEADER_NO_BITS + \
|
#define TAK_FRAME_FLAG_HAS_METADATA 0x4
|
||||||
TAK_CRC24_BITS )
|
|
||||||
|
|
||||||
#define TAK_MIN_FRAME_HEADER_LAST_BITS ( TAK_MIN_FRAME_HEADER_BITS + 2 + \
|
#define TAK_MAX_CHANNELS (1 << TAK_FORMAT_CHANNEL_BITS)
|
||||||
TAK_FRAME_HEADER_SAMPLE_COUNT_BITS )
|
|
||||||
|
|
||||||
#define TAK_ENCODER_BITS ( TAK_ENCODER_CODEC_BITS + \
|
#define TAK_MIN_FRAME_HEADER_BITS (TAK_FRAME_HEADER_SYNC_ID_BITS + \
|
||||||
TAK_ENCODER_PROFILE_BITS )
|
TAK_FRAME_HEADER_FLAGS_BITS + \
|
||||||
|
TAK_FRAME_HEADER_NO_BITS + \
|
||||||
|
TAK_CRC24_BITS)
|
||||||
|
|
||||||
#define TAK_SIZE_BITS ( TAK_SIZE_SAMPLES_NUM_BITS + \
|
#define TAK_MIN_FRAME_HEADER_LAST_BITS (TAK_MIN_FRAME_HEADER_BITS + 2 + \
|
||||||
TAK_SIZE_FRAME_DURATION_BITS )
|
TAK_FRAME_HEADER_SAMPLE_COUNT_BITS)
|
||||||
|
|
||||||
#define TAK_FORMAT_BITS ( TAK_FORMAT_DATA_TYPE_BITS + \
|
#define TAK_ENCODER_BITS (TAK_ENCODER_CODEC_BITS + \
|
||||||
TAK_FORMAT_SAMPLE_RATE_BITS + \
|
TAK_ENCODER_PROFILE_BITS)
|
||||||
TAK_FORMAT_BPS_BITS + \
|
|
||||||
TAK_FORMAT_CHANNEL_BITS + 1 + \
|
|
||||||
TAK_FORMAT_VALID_BITS + 1 + \
|
|
||||||
TAK_FORMAT_CH_LAYOUT_BITS * \
|
|
||||||
TAK_MAX_CHANNELS )
|
|
||||||
|
|
||||||
#define TAK_STREAMINFO_BITS ( TAK_ENCODER_BITS + \
|
#define TAK_SIZE_BITS (TAK_SIZE_SAMPLES_NUM_BITS + \
|
||||||
TAK_SIZE_BITS + \
|
TAK_SIZE_FRAME_DURATION_BITS)
|
||||||
TAK_FORMAT_BITS )
|
|
||||||
|
|
||||||
#define TAK_MAX_FRAME_HEADER_BITS ( TAK_MIN_FRAME_HEADER_LAST_BITS + \
|
#define TAK_FORMAT_BITS (TAK_FORMAT_DATA_TYPE_BITS + \
|
||||||
TAK_STREAMINFO_BITS + 31 )
|
TAK_FORMAT_SAMPLE_RATE_BITS + \
|
||||||
|
TAK_FORMAT_BPS_BITS + \
|
||||||
|
TAK_FORMAT_CHANNEL_BITS + 1 + \
|
||||||
|
TAK_FORMAT_VALID_BITS + 1 + \
|
||||||
|
TAK_FORMAT_CH_LAYOUT_BITS * \
|
||||||
|
TAK_MAX_CHANNELS)
|
||||||
|
|
||||||
#define TAK_STREAMINFO_BYTES (( TAK_STREAMINFO_BITS + 7 ) / 8)
|
#define TAK_STREAMINFO_BITS (TAK_ENCODER_BITS + \
|
||||||
#define TAK_MAX_FRAME_HEADER_BYTES (( TAK_MAX_FRAME_HEADER_BITS + 7 ) / 8)
|
TAK_SIZE_BITS + \
|
||||||
#define TAK_MIN_FRAME_HEADER_BYTES (( TAK_MIN_FRAME_HEADER_BITS + 7 ) / 8)
|
TAK_FORMAT_BITS)
|
||||||
|
|
||||||
|
#define TAK_MAX_FRAME_HEADER_BITS (TAK_MIN_FRAME_HEADER_LAST_BITS + \
|
||||||
|
TAK_STREAMINFO_BITS + 31)
|
||||||
|
|
||||||
|
#define TAK_STREAMINFO_BYTES ((TAK_STREAMINFO_BITS + 7) / 8)
|
||||||
|
#define TAK_MAX_FRAME_HEADER_BYTES ((TAK_MAX_FRAME_HEADER_BITS + 7) / 8)
|
||||||
|
#define TAK_MIN_FRAME_HEADER_BYTES ((TAK_MIN_FRAME_HEADER_BITS + 7) / 8)
|
||||||
|
|
||||||
|
enum TAKCodecType {
|
||||||
|
TAK_CODEC_MONO_STEREO = 2,
|
||||||
|
TAK_CODEC_MULTICHANNEL = 4,
|
||||||
|
};
|
||||||
|
|
||||||
enum TAKMetaDataType {
|
enum TAKMetaDataType {
|
||||||
TAK_METADATA_END = 0,
|
TAK_METADATA_END = 0,
|
||||||
@ -117,16 +127,17 @@ enum TAKFrameSizeType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct TAKStreamInfo {
|
typedef struct TAKStreamInfo {
|
||||||
int codec;
|
int flags;
|
||||||
int data_type;
|
enum TAKCodecType codec;
|
||||||
int sample_rate;
|
int data_type;
|
||||||
int channels;
|
int sample_rate;
|
||||||
int bps;
|
int channels;
|
||||||
int frame_num;
|
int bps;
|
||||||
int frame_samples;
|
int frame_num;
|
||||||
int last_frame_samples;
|
int frame_samples;
|
||||||
uint64_t ch_layout;
|
int last_frame_samples;
|
||||||
int64_t samples;
|
uint64_t ch_layout;
|
||||||
|
int64_t samples;
|
||||||
} TAKStreamInfo;
|
} TAKStreamInfo;
|
||||||
|
|
||||||
void ff_tak_init_crc(void);
|
void ff_tak_init_crc(void);
|
||||||
@ -145,8 +156,9 @@ void avpriv_tak_parse_streaminfo(GetBitContext *gb, TAKStreamInfo *s);
|
|||||||
* @param avctx AVCodecContext to use as av_log() context
|
* @param avctx AVCodecContext to use as av_log() context
|
||||||
* @param[in] gb GetBitContext from which to read frame header
|
* @param[in] gb GetBitContext from which to read frame header
|
||||||
* @param[out] s frame information
|
* @param[out] s frame information
|
||||||
* @param log_level_offset log level offset. can be used to silence error messages.
|
* @param log_level_offset log level offset, can be used to silence
|
||||||
* @return non-zero on error, 0 if ok
|
* error messages.
|
||||||
|
* @return non-zero on error, 0 if OK
|
||||||
*/
|
*/
|
||||||
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
|
||||||
TAKStreamInfo *s, int log_level_offset);
|
TAKStreamInfo *s, int log_level_offset);
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
* TAK parser
|
* TAK parser
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "parser.h"
|
|
||||||
#include "tak.h"
|
#include "tak.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
typedef struct TAKParseContext {
|
typedef struct TAKParseContext {
|
||||||
ParseContext pc;
|
ParseContext pc;
|
||||||
@ -44,18 +44,18 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
const uint8_t *buf, int buf_size)
|
const uint8_t *buf, int buf_size)
|
||||||
{
|
{
|
||||||
TAKParseContext *t = s->priv_data;
|
TAKParseContext *t = s->priv_data;
|
||||||
ParseContext *pc = &t->pc;
|
ParseContext *pc = &t->pc;
|
||||||
int next = END_NOT_FOUND;
|
int next = END_NOT_FOUND;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int consumed = 0;
|
int consumed = 0;
|
||||||
int needed = buf_size ? TAK_MAX_FRAME_HEADER_BYTES : 8;
|
int needed = buf_size ? TAK_MAX_FRAME_HEADER_BYTES : 8;
|
||||||
|
|
||||||
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
|
||||||
TAKStreamInfo ti;
|
TAKStreamInfo ti;
|
||||||
init_get_bits(&gb, buf, buf_size);
|
init_get_bits(&gb, buf, buf_size);
|
||||||
if (!ff_tak_decode_frame_header(avctx, &gb, &ti, 127))
|
if (!ff_tak_decode_frame_header(avctx, &gb, &ti, 127))
|
||||||
s->duration = t->ti.last_frame_samples ? t->ti.last_frame_samples :
|
s->duration = t->ti.last_frame_samples ? t->ti.last_frame_samples
|
||||||
t->ti.frame_samples;
|
: t->ti.frame_samples;
|
||||||
*poutbuf = buf;
|
*poutbuf = buf;
|
||||||
*poutbuf_size = buf_size;
|
*poutbuf_size = buf_size;
|
||||||
return buf_size;
|
return buf_size;
|
||||||
@ -63,7 +63,8 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
|
|
||||||
while (buf_size || t->index + needed <= pc->index) {
|
while (buf_size || t->index + needed <= pc->index) {
|
||||||
if (buf_size && t->index + TAK_MAX_FRAME_HEADER_BYTES > pc->index) {
|
if (buf_size && t->index + TAK_MAX_FRAME_HEADER_BYTES > pc->index) {
|
||||||
int tmp_buf_size = FFMIN(2 * TAK_MAX_FRAME_HEADER_BYTES, buf_size);
|
int tmp_buf_size = FFMIN(2 * TAK_MAX_FRAME_HEADER_BYTES,
|
||||||
|
buf_size);
|
||||||
const uint8_t *tmp_buf = buf;
|
const uint8_t *tmp_buf = buf;
|
||||||
|
|
||||||
if (ff_combine_frame(pc, END_NOT_FOUND, &tmp_buf, &tmp_buf_size) != -1)
|
if (ff_combine_frame(pc, END_NOT_FOUND, &tmp_buf, &tmp_buf_size) != -1)
|
||||||
@ -86,13 +87,13 @@ static int tak_parse(AVCodecParserContext *s, AVCodecContext *avctx,
|
|||||||
get_bits_count(&gb) / 8)) {
|
get_bits_count(&gb) / 8)) {
|
||||||
if (!pc->frame_start_found) {
|
if (!pc->frame_start_found) {
|
||||||
pc->frame_start_found = 1;
|
pc->frame_start_found = 1;
|
||||||
s->duration = t->ti.last_frame_samples ?
|
s->duration = t->ti.last_frame_samples ?
|
||||||
t->ti.last_frame_samples :
|
t->ti.last_frame_samples :
|
||||||
t->ti.frame_samples;
|
t->ti.frame_samples;
|
||||||
} else {
|
} else {
|
||||||
pc->frame_start_found = 0;
|
pc->frame_start_found = 0;
|
||||||
next = t->index - pc->index;
|
next = t->index - pc->index;
|
||||||
t->index = 0;
|
t->index = 0;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ found:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next != END_NOT_FOUND) {
|
if (next != END_NOT_FOUND) {
|
||||||
next += consumed;
|
next += consumed;
|
||||||
pc->overread = FFMAX(0, -next);
|
pc->overread = FFMAX(0, -next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,8 +26,8 @@
|
|||||||
#include "apetag.h"
|
#include "apetag.h"
|
||||||
|
|
||||||
typedef struct TAKDemuxContext {
|
typedef struct TAKDemuxContext {
|
||||||
int mlast_frame;
|
int mlast_frame;
|
||||||
int64_t data_end;
|
int64_t data_end;
|
||||||
} TAKDemuxContext;
|
} TAKDemuxContext;
|
||||||
|
|
||||||
static int tak_probe(AVProbeData *p)
|
static int tak_probe(AVProbeData *p)
|
||||||
@ -40,7 +40,7 @@ static int tak_probe(AVProbeData *p)
|
|||||||
static int tak_read_header(AVFormatContext *s)
|
static int tak_read_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
TAKDemuxContext *tc = s->priv_data;
|
TAKDemuxContext *tc = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
uint8_t *buffer = NULL;
|
uint8_t *buffer = NULL;
|
||||||
@ -95,7 +95,7 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
av_log(s, AV_LOG_VERBOSE, "%02x", md5[i]);
|
av_log(s, AV_LOG_VERBOSE, "%02x", md5[i]);
|
||||||
av_log(s, AV_LOG_VERBOSE, "\n");
|
av_log(s, AV_LOG_VERBOSE, "\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TAK_METADATA_END: {
|
case TAK_METADATA_END: {
|
||||||
int64_t curpos = avio_tell(pb);
|
int64_t curpos = avio_tell(pb);
|
||||||
|
|
||||||
@ -106,8 +106,7 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
|
|
||||||
tc->data_end += curpos;
|
tc->data_end += curpos;
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
ret = avio_skip(pb, size);
|
ret = avio_skip(pb, size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -123,19 +122,19 @@ static int tak_read_header(AVFormatContext *s)
|
|||||||
st->codec->bits_per_coded_sample = ti.bps;
|
st->codec->bits_per_coded_sample = ti.bps;
|
||||||
if (ti.ch_layout)
|
if (ti.ch_layout)
|
||||||
st->codec->channel_layout = ti.ch_layout;
|
st->codec->channel_layout = ti.ch_layout;
|
||||||
st->codec->sample_rate = ti.sample_rate;
|
st->codec->sample_rate = ti.sample_rate;
|
||||||
st->codec->channels = ti.channels;
|
st->codec->channels = ti.channels;
|
||||||
st->start_time = 0;
|
st->start_time = 0;
|
||||||
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
||||||
st->codec->extradata = buffer;
|
st->codec->extradata = buffer;
|
||||||
st->codec->extradata_size = size;
|
st->codec->extradata_size = size;
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
} else if (type == TAK_METADATA_LAST_FRAME) {
|
} else if (type == TAK_METADATA_LAST_FRAME) {
|
||||||
if (size != 11)
|
if (size != 11)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
tc->mlast_frame = 1;
|
tc->mlast_frame = 1;
|
||||||
tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
|
tc->data_end = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
|
||||||
get_bits(&gb, TAK_LAST_FRAME_SIZE_BITS);
|
get_bits(&gb, TAK_LAST_FRAME_SIZE_BITS);
|
||||||
av_freep(&buffer);
|
av_freep(&buffer);
|
||||||
} else if (type == TAK_METADATA_ENCODER) {
|
} else if (type == TAK_METADATA_ENCODER) {
|
||||||
av_log(s, AV_LOG_VERBOSE, "encoder version: %0X\n",
|
av_log(s, AV_LOG_VERBOSE, "encoder version: %0X\n",
|
||||||
|
Reference in New Issue
Block a user