本文整理汇总了C++中MKTAG函数的典型用法代码示例。如果您正苦于以下问题:C++ MKTAG函数的具体用法?C++ MKTAG怎么用?C++ MKTAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MKTAG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_header
static int read_header(AVFormatContext *s)
{
BRSTMDemuxContext *b = s->priv_data;
int bom, major, minor, codec, chunk;
int64_t pos, h1offset, toffset;
uint32_t size, start, asize;
AVStream *st;
int ret = AVERROR_EOF;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
bom = avio_rb16(s->pb);
if (bom != 0xFEFF && bom != 0xFFFE) {
av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
return AVERROR_INVALIDDATA;
}
if (bom == 0xFFFE) {
avpriv_request_sample(s, "little endian byte order");
return AVERROR_PATCHWELCOME;
}
major = avio_r8(s->pb);
minor = avio_r8(s->pb);
avio_skip(s->pb, 4); // size of file
size = avio_rb16(s->pb);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, size - 14);
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
size = avio_rb32(s->pb);
if (size < 256)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 4); // unknown
h1offset = avio_rb32(s->pb);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 12);
toffset = avio_rb32(s->pb) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
codec = avio_r8(s->pb);
switch (codec) {
case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: codec = AV_CODEC_ID_PCM_S16BE_PLANAR; break;
case 2: codec = AV_CODEC_ID_ADPCM_THP; break;
default:
avpriv_request_sample(s, "codec %d", codec);
return AVERROR_PATCHWELCOME;
}
avio_skip(s->pb, 1); // loop flag
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1); // padding
st->codec->sample_rate = avio_rb16(s->pb);
if (!st->codec->sample_rate)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 2); // padding
avio_skip(s->pb, 4); // loop start sample
st->start_time = 0;
st->duration = avio_rb32(s->pb);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
start = avio_rb32(s->pb);
b->current_block = 0;
b->block_count = avio_rb32(s->pb);
if (b->block_count > UINT16_MAX) {
av_log(s, AV_LOG_WARNING, "too many blocks: %u\n", b->block_count);
return AVERROR_INVALIDDATA;
}
b->block_size = avio_rb32(s->pb);
if (b->block_size > UINT16_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
b->block_size *= st->codec->channels;
b->samples_per_block = avio_rb32(s->pb);
b->last_block_used_bytes = avio_rb32(s->pb);
if (b->last_block_used_bytes > UINT16_MAX / st->codec->channels)
return AVERROR_INVALIDDATA;
b->last_block_used_bytes *= st->codec->channels;
avio_skip(s->pb, 4); // last block samples
avio_skip(s->pb, 4); // last block size
//.........这里部分代码省略.........
示例2: MKTAG
bool AVIDecoder::AVIVideoTrack::isTruemotion1() const {
return _bmInfo.compression == MKTAG('D', 'U', 'C', 'K') || _bmInfo.compression == MKTAG('d', 'u', 'c', 'k');
}
示例3: img_write_packet
static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
{
VideoData *img = s->priv_data;
ByteIOContext *pb[3];
char filename[1024];
AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec;
int i;
if (!img->is_pipe) {
if (av_get_frame_filename(filename, sizeof(filename),
img->path, img->img_number) < 0 && img->img_number>1) {
av_log(s, AV_LOG_ERROR, "Could not get frame filename from pattern\n");
return AVERROR(EIO);
}
for(i=0; i<3; i++){
if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) {
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n",filename);
return AVERROR(EIO);
}
if(codec->codec_id != CODEC_ID_RAWVIDEO)
break;
filename[ strlen(filename) - 1 ]= 'U' + i;
}
} else {
pb[0] = s->pb;
}
if(codec->codec_id == CODEC_ID_RAWVIDEO){
int ysize = codec->width * codec->height;
put_buffer(pb[0], pkt->data , ysize);
put_buffer(pb[1], pkt->data + ysize, (pkt->size - ysize)/2);
put_buffer(pb[2], pkt->data + ysize +(pkt->size - ysize)/2, (pkt->size - ysize)/2);
put_flush_packet(pb[1]);
put_flush_packet(pb[2]);
url_fclose(pb[1]);
url_fclose(pb[2]);
}else{
if(av_str2id(img_tags, s->filename) == CODEC_ID_JPEG2000){
AVStream *st = s->streams[0];
if(st->codec->extradata_size > 8 &&
AV_RL32(st->codec->extradata+4) == MKTAG('j','p','2','h')){
if(pkt->size < 8 || AV_RL32(pkt->data+4) != MKTAG('j','p','2','c'))
goto error;
put_be32(pb[0], 12);
put_tag (pb[0], "jP ");
put_be32(pb[0], 0x0D0A870A); // signature
put_be32(pb[0], 20);
put_tag (pb[0], "ftyp");
put_tag (pb[0], "jp2 ");
put_be32(pb[0], 0);
put_tag (pb[0], "jp2 ");
put_buffer(pb[0], st->codec->extradata, st->codec->extradata_size);
}else if(pkt->size < 8 ||
(!st->codec->extradata_size &&
AV_RL32(pkt->data+4) != MKTAG('j','P',' ',' '))){ // signature
error:
av_log(s, AV_LOG_ERROR, "malformated jpeg2000 codestream\n");
return -1;
}
}
put_buffer(pb[0], pkt->data, pkt->size);
}
put_flush_packet(pb[0]);
if (!img->is_pipe) {
url_fclose(pb[0]);
}
img->img_number++;
return 0;
}
示例4: mmf_read_header
/* mmf input */
static int mmf_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
MMFContext *mmf = s->priv_data;
unsigned int tag;
ByteIOContext *pb = &s->pb;
AVStream *st;
offset_t file_size, size;
int rate, params;
tag = get_le32(pb);
if (tag != MKTAG('M', 'M', 'M', 'D'))
return -1;
file_size = get_be32(pb);
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
tag = get_le32(pb);
size = get_be32(pb);
if(tag == MKTAG('C','N','T','I')) continue;
if(tag == MKTAG('O','P','D','A')) continue;
break;
}
/* Tag = "ATRx", where "x" = track number */
if ((tag & 0xffffff) == MKTAG('M', 'T', 'R', 0)) {
av_log(s, AV_LOG_ERROR, "MIDI like format found, unsupported\n");
return -1;
}
if ((tag & 0xffffff) != MKTAG('A', 'T', 'R', 0)) {
av_log(s, AV_LOG_ERROR, "Unsupported SMAF chunk %08x\n", tag);
return -1;
}
get_byte(pb); /* format type */
get_byte(pb); /* sequence type */
params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */
rate = mmf_rate(params & 0x0f);
if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
return -1;
}
get_byte(pb); /* wave base bit */
get_byte(pb); /* time base d */
get_byte(pb); /* time base g */
/* Skip some unused chunks that may or may not be present */
for(;; url_fseek(pb, size, SEEK_CUR)) {
tag = get_le32(pb);
size = get_be32(pb);
if(tag == MKTAG('A','t','s','q')) continue;
if(tag == MKTAG('A','s','p','I')) continue;
break;
}
/* Make sure it's followed by an Awa chunk, aka wave data */
if ((tag & 0xffffff) != MKTAG('A', 'w', 'a', 0)) {
av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag);
return -1;
}
mmf->data_size = size;
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_ADPCM_YAMAHA;
st->codec->sample_rate = rate;
st->codec->channels = 1;
st->codec->bits_per_sample = 4;
st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_sample;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
return 0;
}
示例5: wv_read_block_header
static int wv_read_block_header(AVFormatContext *ctx, ByteIOContext *pb)
{
WVContext *wc = ctx->priv_data;
uint32_t tag, ver;
int size;
int rate, bpp, chan;
wc->pos = url_ftell(pb);
tag = get_le32(pb);
if (tag != MKTAG('w', 'v', 'p', 'k'))
return -1;
size = get_le32(pb);
if(size < 24 || size > WV_BLOCK_LIMIT){
av_log(ctx, AV_LOG_ERROR, "Incorrect block size %i\n", size);
return -1;
}
wc->blksize = size;
ver = get_le16(pb);
if(ver < 0x402 || ver > 0x410){
av_log(ctx, AV_LOG_ERROR, "Unsupported version %03X\n", ver);
return -1;
}
get_byte(pb); // track no
get_byte(pb); // track sub index
wc->samples = get_le32(pb); // total samples in file
wc->soff = get_le32(pb); // offset in samples of current block
get_buffer(pb, wc->extra, WV_EXTRA_SIZE);
wc->flags = AV_RL32(wc->extra + 4);
//parse flags
bpp = ((wc->flags & 3) + 1) << 3;
chan = 1 + !(wc->flags & WV_MONO);
rate = wv_rates[(wc->flags >> 23) & 0xF];
if(rate == -1 && !wc->block_parsed){
int64_t block_end = url_ftell(pb) + wc->blksize - 24;
if(url_is_streamed(pb)){
av_log(ctx, AV_LOG_ERROR, "Cannot determine custom sampling rate\n");
return -1;
}
while(url_ftell(pb) < block_end){
int id, size;
id = get_byte(pb);
size = (id & 0x80) ? get_le24(pb) : get_byte(pb);
size <<= 1;
if(id&0x40)
size--;
if((id&0x3F) == 0x27){
rate = get_le24(pb);
break;
}else{
url_fskip(pb, size);
}
}
if(rate == -1){
av_log(ctx, AV_LOG_ERROR, "Cannot determine custom sampling rate\n");
return -1;
}
url_fseek(pb, block_end - wc->blksize + 24, SEEK_SET);
}
if(!wc->bpp) wc->bpp = bpp;
if(!wc->chan) wc->chan = chan;
if(!wc->rate) wc->rate = rate;
if(wc->flags && bpp != wc->bpp){
av_log(ctx, AV_LOG_ERROR, "Bits per sample differ, this block: %i, header block: %i\n", bpp, wc->bpp);
return -1;
}
if(wc->flags && chan != wc->chan){
av_log(ctx, AV_LOG_ERROR, "Channels differ, this block: %i, header block: %i\n", chan, wc->chan);
return -1;
}
if(wc->flags && rate != -1 && rate != wc->rate){
av_log(ctx, AV_LOG_ERROR, "Sampling rate differ, this block: %i, header block: %i\n", rate, wc->rate);
return -1;
}
wc->blksize = size - 24;
return 0;
}
示例6: ffm_write_header
static int ffm_write_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVDictionaryEntry *t;
AVStream *st;
AVIOContext *pb = s->pb;
AVCodecContext *codec;
int bit_rate, i, ret;
if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) {
ret = av_parse_time(&ffm->start_time, t->value, 0);
if (ret < 0)
return ret;
}
ffm->packet_size = FFM_PACKET_SIZE;
/* header */
avio_wl32(pb, MKTAG('F', 'F', 'M', '2'));
avio_wb32(pb, ffm->packet_size);
avio_wb64(pb, 0); /* current write position */
if(avio_open_dyn_buf(&pb) < 0)
return AVERROR(ENOMEM);
avio_wb32(pb, s->nb_streams);
bit_rate = 0;
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
bit_rate += st->codec->bit_rate;
}
avio_wb32(pb, bit_rate);
write_header_chunk(s->pb, pb, MKBETAG('M', 'A', 'I', 'N'));
/* list of streams */
for(i=0;i<s->nb_streams;i++) {
st = s->streams[i];
avpriv_set_pts_info(st, 64, 1, 1000000);
if(avio_open_dyn_buf(&pb) < 0)
return AVERROR(ENOMEM);
codec = st->codec;
/* generic info */
avio_wb32(pb, codec->codec_id);
avio_w8(pb, codec->codec_type);
avio_wb32(pb, codec->bit_rate);
avio_wb32(pb, codec->flags);
avio_wb32(pb, codec->flags2);
avio_wb32(pb, codec->debug);
if (codec->flags & CODEC_FLAG_GLOBAL_HEADER) {
avio_wb32(pb, codec->extradata_size);
avio_write(pb, codec->extradata, codec->extradata_size);
}
write_header_chunk(s->pb, pb, MKBETAG('C', 'O', 'M', 'M'));
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (st->recommended_encoder_configuration) {
av_log(NULL, AV_LOG_DEBUG, "writing recommended configuration: %s\n",
st->recommended_encoder_configuration);
if ((ret = ffm_write_recommended_config(s->pb, codec, MKBETAG('S', '2', 'V', 'I'),
st->recommended_encoder_configuration)) < 0)
return ret;
} else if ((ret = ffm_write_header_codec_ctx(s->pb, codec, MKBETAG('S', '2', 'V', 'I'), AV_OPT_FLAG_VIDEO_PARAM)) < 0 ||
(ret = ffm_write_header_codec_private_ctx(s, codec, AV_OPT_FLAG_VIDEO_PARAM)) < 0)
return ret;
break;
case AVMEDIA_TYPE_AUDIO:
if (st->recommended_encoder_configuration) {
av_log(NULL, AV_LOG_DEBUG, "writing recommended configuration: %s\n",
st->recommended_encoder_configuration);
if ((ret = ffm_write_recommended_config(s->pb, codec, MKBETAG('S', '2', 'A', 'U'),
st->recommended_encoder_configuration)) < 0)
return ret;
} else if ((ret = ffm_write_header_codec_ctx(s->pb, codec, MKBETAG('S', '2', 'A', 'U'), AV_OPT_FLAG_AUDIO_PARAM)) < 0 ||
(ret = ffm_write_header_codec_private_ctx(s, codec, AV_OPT_FLAG_AUDIO_PARAM)) < 0)
return ret;
break;
default:
return -1;
}
}
pb = s->pb;
avio_wb64(pb, 0); // end of header
/* flush until end of block reached */
while ((avio_tell(pb) % ffm->packet_size) != 0)
avio_w8(pb, 0);
avio_flush(pb);
/* init packet mux */
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet + ffm->packet_size - FFM_HEADER_SIZE;
av_assert0(ffm->packet_end >= ffm->packet);
ffm->frame_offset = 0;
ffm->dts = 0;
ffm->first_packet = 1;
//.........这里部分代码省略.........
示例7: read_header
static int read_header(AVFormatContext *s)
{
BRSTMDemuxContext *b = s->priv_data;
int bom, major, minor, codec, chunk;
int64_t h1offset, pos, toffset;
uint32_t size, asize, start = 0;
AVStream *st;
int ret = AVERROR_EOF;
int bfstm = !strcmp("bfstm", s->iformat->name);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
bom = avio_rb16(s->pb);
if (bom != 0xFEFF && bom != 0xFFFE) {
av_log(s, AV_LOG_ERROR, "invalid byte order: %X\n", bom);
return AVERROR_INVALIDDATA;
}
if (bom == 0xFFFE)
b->little_endian = 1;
if (!bfstm) {
major = avio_r8(s->pb);
minor = avio_r8(s->pb);
avio_skip(s->pb, 4); // size of file
size = read16(s);
if (size < 14)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, size - 14);
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
return AVERROR_INVALIDDATA;
} else {
uint32_t info_offset = 0, info_size;
uint16_t section_count, header_size, i;
header_size = read16(s); // 6
avio_skip(s->pb, 4); // Unknown constant 0x00030000
avio_skip(s->pb, 4); // size of file
section_count = read16(s);
avio_skip(s->pb, 2); // padding
for (i = 0; avio_tell(s->pb) < header_size
&& !(start && info_offset)
&& i < section_count; i++) {
uint16_t flag = read16(s);
avio_skip(s->pb, 2);
switch (flag) {
case 0x4000:
info_offset = read32(s);
info_size = read32(s);
break;
case 0x4001:
avio_skip(s->pb, 4); // seek offset
avio_skip(s->pb, 4); // seek size
break;
case 0x4002:
start = read32(s) + 8;
avio_skip(s->pb, 4); //data_size = read32(s);
break;
case 0x4003:
avio_skip(s->pb, 4); // REGN offset
avio_skip(s->pb, 4); // REGN size
break;
}
}
if (!info_offset || !start)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, info_offset - avio_tell(s->pb));
pos = avio_tell(s->pb);
if (avio_rl32(s->pb) != MKTAG('I','N','F','O'))
return AVERROR_INVALIDDATA;
}
size = read32(s);
if (size < 192)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 4); // unknown
h1offset = read32(s);
if (h1offset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 12);
toffset = read32(s) + 16LL;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + h1offset + 8 - avio_tell(s->pb));
codec = avio_r8(s->pb);
switch (codec) {
case 0: codec = AV_CODEC_ID_PCM_S8_PLANAR; break;
case 1: codec = b->little_endian ?
//.........这里部分代码省略.........
示例8: caf_write_header
static int caf_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
CAFContext *caf = s->priv_data;
unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id);
switch (enc->codec_id) {
case CODEC_ID_AAC:
case CODEC_ID_AC3:
av_log(s, AV_LOG_ERROR, "muxing codec currently unsupported\n");
return AVERROR_PATCHWELCOME;
}
switch (enc->codec_id) {
case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_S24LE:
case CODEC_ID_PCM_S24BE:
case CODEC_ID_PCM_S32LE:
case CODEC_ID_PCM_S32BE:
case CODEC_ID_PCM_F32LE:
case CODEC_ID_PCM_F32BE:
case CODEC_ID_PCM_F64LE:
case CODEC_ID_PCM_F64BE:
case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW:
codec_tag = MKTAG('l','p','c','m');
}
if (!codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR_INVALIDDATA;
}
if (!enc->block_align && !pb->seekable) {
av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n");
return AVERROR_INVALIDDATA;
}
ffio_wfourcc(pb, "caff"); //< mFileType
avio_wb16(pb, 1); //< mFileVersion
avio_wb16(pb, 0); //< mFileFlags
ffio_wfourcc(pb, "desc"); //< Audio Description chunk
avio_wb64(pb, 32); //< mChunkSize
avio_wb64(pb, av_dbl2int(enc->sample_rate)); //< mSampleRate
avio_wl32(pb, codec_tag); //< mFormatID
avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags
avio_wb32(pb, enc->block_align); //< mBytesPerPacket
avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket
avio_wb32(pb, enc->channels); //< mChannelsPerFrame
avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel
if (enc->channel_layout) {
ffio_wfourcc(pb, "chan");
avio_wb64(pb, 12);
ff_mov_write_chan(pb, enc->channel_layout);
}
if (enc->codec_id == CODEC_ID_ALAC) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, 12 + enc->extradata_size);
avio_write(pb, "\0\0\0\14frmaalac", 12);
avio_write(pb, enc->extradata, enc->extradata_size);
} else if (enc->codec_id == CODEC_ID_AMR_NB) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, 29);
avio_write(pb, "\0\0\0\14frmasamr", 12);
avio_wb32(pb, 0x11); /* size */
avio_write(pb, "samrFFMP", 8);
avio_w8(pb, 0); /* decoder version */
avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
avio_w8(pb, 0x00); /* Mode change period (no restriction) */
avio_w8(pb, 0x01); /* Frames per sample */
} else if (enc->codec_id == CODEC_ID_QDM2) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, enc->extradata_size);
avio_write(pb, enc->extradata, enc->extradata_size);
}
ffio_wfourcc(pb, "data"); //< Audio Data chunk
caf->data = avio_tell(pb);
avio_wb64(pb, -1); //< mChunkSize
avio_wb32(pb, 0); //< mEditCount
avio_flush(pb);
return 0;
}
示例9: get_codec_data
/**
* @brief read until we found all data needed for decoding
* @param vst video stream of which to change parameters
* @param ast video stream of which to change parameters
* @param myth set if this is a MythTVVideo format file
* @return 1 if all required codec data was found
*/
static int get_codec_data(AVIOContext *pb, AVStream *vst,
AVStream *ast, int myth) {
nuv_frametype frametype;
if (!vst && !myth)
return 1; // no codec data needed
while (!url_feof(pb)) {
int size, subtype;
frametype = avio_r8(pb);
switch (frametype) {
case NUV_EXTRADATA:
subtype = avio_r8(pb);
avio_skip(pb, 6);
size = PKTSIZE(avio_rl32(pb));
if (vst && subtype == 'R') {
vst->codec->extradata_size = size;
vst->codec->extradata = av_malloc(size);
avio_read(pb, vst->codec->extradata, size);
size = 0;
if (!myth)
return 1;
}
break;
case NUV_MYTHEXT:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
if (size != 128 * 4)
break;
avio_rl32(pb); // version
if (vst) {
vst->codec->codec_tag = avio_rl32(pb);
vst->codec->codec_id =
ff_codec_get_id(ff_codec_bmp_tags, vst->codec->codec_tag);
if (vst->codec->codec_tag == MKTAG('R', 'J', 'P', 'G'))
vst->codec->codec_id = CODEC_ID_NUV;
} else
avio_skip(pb, 4);
if (ast) {
ast->codec->codec_tag = avio_rl32(pb);
ast->codec->sample_rate = avio_rl32(pb);
ast->codec->bits_per_coded_sample = avio_rl32(pb);
ast->codec->channels = avio_rl32(pb);
ast->codec->codec_id =
ff_wav_codec_get_id(ast->codec->codec_tag,
ast->codec->bits_per_coded_sample);
ast->need_parsing = AVSTREAM_PARSE_FULL;
} else
avio_skip(pb, 4 * 4);
size -= 6 * 4;
avio_skip(pb, size);
return 1;
case NUV_SEEKP:
size = 11;
break;
default:
avio_skip(pb, 7);
size = PKTSIZE(avio_rl32(pb));
break;
}
avio_skip(pb, size);
}
return 0;
}
示例10: xwma_read_header
static int xwma_read_header(AVFormatContext *s)
{
int64_t size;
int ret;
uint32_t dpds_table_size = 0;
uint32_t *dpds_table = 0;
unsigned int tag;
AVIOContext *pb = s->pb;
AVStream *st;
XWMAContext *xwma = s->priv_data;
int i;
/* The following code is mostly copied from wav.c, with some
* minor alterations.
*/
/* check RIFF header */
tag = avio_rl32(pb);
if (tag != MKTAG('R', 'I', 'F', 'F'))
return -1;
avio_rl32(pb); /* file size */
tag = avio_rl32(pb);
if (tag != MKTAG('X', 'W', 'M', 'A'))
return -1;
/* parse fmt header */
tag = avio_rl32(pb);
if (tag != MKTAG('f', 'm', 't', ' '))
return -1;
size = avio_rl32(pb);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
ret = ff_get_wav_header(pb, st->codec, size);
if (ret < 0)
return ret;
st->need_parsing = AVSTREAM_PARSE_NONE;
/* All xWMA files I have seen contained WMAv2 data. If there are files
* using WMA Pro or some other codec, then we need to figure out the right
* extradata for that. Thus, ask the user for feedback, but try to go on
* anyway.
*/
if (st->codec->codec_id != CODEC_ID_WMAV2) {
av_log(s, AV_LOG_WARNING, "unexpected codec (tag 0x04%x; id %d)\n",
st->codec->codec_tag, st->codec->codec_id);
av_log_ask_for_sample(s, NULL);
} else {
/* In all xWMA files I have seen, there is no extradata. But the WMA
* codecs require extradata, so we provide our own fake extradata.
*
* First, check that there really was no extradata in the header. If
* there was, then try to use it, after asking the user to provide a
* sample of this unusual file.
*/
if (st->codec->extradata_size != 0) {
/* Surprise, surprise: We *did* get some extradata. No idea
* if it will work, but just go on and try it, after asking
* the user for a sample.
*/
av_log(s, AV_LOG_WARNING, "unexpected extradata (%d bytes)\n",
st->codec->extradata_size);
av_log_ask_for_sample(s, NULL);
} else {
st->codec->extradata_size = 6;
st->codec->extradata = av_mallocz(6 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
/* setup extradata with our experimentally obtained value */
st->codec->extradata[4] = 31;
}
}
if (!st->codec->channels) {
av_log(s, AV_LOG_WARNING, "Invalid channel count: %d\n",
st->codec->channels);
return AVERROR_INVALIDDATA;
}
if (!st->codec->bits_per_coded_sample) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codec->bits_per_coded_sample);
return AVERROR_INVALIDDATA;
}
/* set the sample rate */
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
/* parse the remaining RIFF chunks */
for (;;) {
if (pb->eof_reached)
return -1;
/* read next chunk tag */
tag = avio_rl32(pb);
size = avio_rl32(pb);
if (tag == MKTAG('d', 'a', 't', 'a')) {
/* We assume that the data chunk comes last. */
break;
} else if (tag == MKTAG('d','p','d','s')) {
//.........这里部分代码省略.........
示例11: MKTAG
* along with xoreos-tools. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
* Our very own intermediate texture format.
* Currently used by NSBTX.
*/
#include "src/common/util.h"
#include "src/common/strutil.h"
#include "src/common/readstream.h"
#include "src/common/error.h"
#include "src/images/xoreositex.h"
static const uint32 kXEOSID = MKTAG('X', 'E', 'O', 'S');
static const uint32 kITEXID = MKTAG('I', 'T', 'E', 'X');
namespace Images {
XEOSITEX::XEOSITEX(Common::SeekableReadStream &xeositex) {
load(xeositex);
}
XEOSITEX::~XEOSITEX() {
}
void XEOSITEX::load(Common::SeekableReadStream &xeositex) {
try {
readHeader(xeositex);
示例12: vfw_read_header
//.........这里部分代码省略.........
bi = av_malloc(bisize);
if(!bi) {
vfw_read_close(s);
return AVERROR(ENOMEM);
}
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
if(!ret)
goto fail_bi;
dump_bih(s, &bi->bmiHeader);
if (ctx->video_size) {
ret = av_parse_video_size(&bi->bmiHeader.biWidth, &bi->bmiHeader.biHeight, ctx->video_size);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
goto fail_bi;
}
}
#if FF_API_FORMAT_PARAMETERS
if (ap->width > 0)
bi->bmiHeader.biWidth = ap->width;
if (ap->height > 0)
bi->bmiHeader.biHeight = ap->height;
#endif
if (0) {
/* For testing yet unsupported compressions
* Copy these values from user-supplied verbose information */
bi->bmiHeader.biWidth = 320;
bi->bmiHeader.biHeight = 240;
bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biBitCount = 12;
bi->bmiHeader.biCompression = MKTAG('I','4','2','0');
bi->bmiHeader.biSizeImage = 115200;
dump_bih(s, &bi->bmiHeader);
}
ret = SendMessage(ctx->hwnd, WM_CAP_SET_VIDEOFORMAT, bisize, (LPARAM) bi);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
goto fail_bi;
}
biCompression = bi->bmiHeader.biCompression;
biBitCount = bi->bmiHeader.biBitCount;
av_free(bi);
/* Set sequence setup */
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
(LPARAM) &cparms);
if(!ret)
goto fail_io;
dump_captureparms(s, &cparms);
cparms.fYield = 1; // Spawn a background thread
cparms.dwRequestMicroSecPerFrame =
(fps.den*1000000) / fps.num;
cparms.fAbortLeftMouse = 0;
cparms.fAbortRightMouse = 0;
cparms.fCaptureAudio = 0;
cparms.vKeyAbort = 0;
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
示例13: close
bool StuffItArchive::open(const Common::String &filename) {
close();
_stream = SearchMan.createReadStreamForMember(filename);
if (!_stream)
return false;
uint32 tag = _stream->readUint32BE();
// Check all the possible FourCC's
bool found = false;
for (int i = 0; i < ARRAYSIZE(s_magicNumbers); i++) {
if (tag == s_magicNumbers[i]) {
found = true;
break;
}
}
// Didn't find one, let's bail out
if (!found) {
close();
return false;
}
/* uint16 fileCount = */ _stream->readUint16BE();
/* uint32 archiveSize = */ _stream->readUint32BE();
// Some sort of second magic number
if (_stream->readUint32BE() != MKTAG('r', 'L', 'a', 'u')) {
close();
return false;
}
/* byte version = */ _stream->readByte(); // meaning not clear
_stream->skip(7); // unknown
while (_stream->pos() < _stream->size() && !_stream->eos()) {
byte resForkCompression = _stream->readByte();
byte dataForkCompression = _stream->readByte();
byte fileNameLength = _stream->readByte();
Common::String name;
for (byte i = 0; i < fileNameLength; i++)
name += (char)_stream->readByte();
// Skip remaining bytes
_stream->skip(63 - fileNameLength);
/* uint32 fileType = */ _stream->readUint32BE();
/* uint32 fileCreator = */ _stream->readUint32BE();
/* uint16 finderFlags = */ _stream->readUint16BE();
/* uint32 creationDate = */ _stream->readUint32BE();
/* uint32 modificationDate = */ _stream->readUint32BE();
uint32 resForkUncompressedSize = _stream->readUint32BE();
uint32 dataForkUncompressedSize = _stream->readUint32BE();
uint32 resForkCompressedSize = _stream->readUint32BE();
uint32 dataForkCompressedSize = _stream->readUint32BE();
/* uint16 resForkCRC = */ _stream->readUint16BE();
/* uint16 dataForkCRC = */ _stream->readUint16BE();
_stream->skip(6); // unknown
/* uint16 headerCRC = */ _stream->readUint16BE();
// Ignore directories for now
if (dataForkCompression == 32 || dataForkCompression == 33)
continue;
if (dataForkUncompressedSize != 0) {
// We have a data fork
FileEntry entry;
entry.compression = dataForkCompression;
entry.uncompressedSize = dataForkUncompressedSize;
entry.compressedSize = dataForkCompressedSize;
entry.offset = _stream->pos() + resForkCompressedSize;
_map[name] = entry;
debug(0, "StuffIt file '%s', Compression = %d", name.c_str(), entry.compression);
}
if (resForkUncompressedSize != 0) {
// We have a resource fork
// Add a .rsrc extension so we know it's the resource fork
name += ".rsrc";
FileEntry entry;
entry.compression = resForkCompression;
entry.uncompressedSize = resForkUncompressedSize;
entry.compressedSize = resForkCompressedSize;
entry.offset = _stream->pos();
_map[name] = entry;
debug(0, "StuffIt file '%s', Compression = %d", name.c_str(), entry.compression);
}
// Go to the next entry
_stream->skip(dataForkCompressedSize + resForkCompressedSize);
//.........这里部分代码省略.........
示例14: DestroyDecoder
STDMETHODIMP CDecAvcodec::InitDecoder(AVCodecID codec, const CMediaType *pmt)
{
DestroyDecoder();
DbgLog((LOG_TRACE, 10, L"Initializing ffmpeg for codec %S", avcodec_get_name(codec)));
BITMAPINFOHEADER *pBMI = NULL;
videoFormatTypeHandler((const BYTE *)pmt->Format(), pmt->FormatType(), &pBMI);
m_pAVCodec = avcodec_find_decoder(codec);
CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);
m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
CheckPointer(m_pAVCtx, E_POINTER);
if(codec == AV_CODEC_ID_MPEG1VIDEO || codec == AV_CODEC_ID_MPEG2VIDEO || pmt->subtype == FOURCCMap(MKTAG('H','2','6','4')) || pmt->subtype == FOURCCMap(MKTAG('h','2','6','4'))) {
m_pParser = av_parser_init(codec);
}
DWORD dwDecFlags = m_pCallback->GetDecodeFlags();
LONG biRealWidth = pBMI->biWidth, biRealHeight = pBMI->biHeight;
if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) {
VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)pmt->Format();
if (vih->rcTarget.right != 0 && vih->rcTarget.bottom != 0) {
biRealWidth = vih->rcTarget.right;
biRealHeight = vih->rcTarget.bottom;
}
} else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2Video) {
VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)pmt->Format();
if (vih2->rcTarget.right != 0 && vih2->rcTarget.bottom != 0) {
biRealWidth = vih2->rcTarget.right;
biRealHeight = vih2->rcTarget.bottom;
}
}
m_pAVCtx->codec_id = codec;
m_pAVCtx->codec_tag = pBMI->biCompression;
m_pAVCtx->coded_width = pBMI->biWidth;
m_pAVCtx->coded_height = abs(pBMI->biHeight);
m_pAVCtx->bits_per_coded_sample = pBMI->biBitCount;
m_pAVCtx->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
m_pAVCtx->err_recognition = AV_EF_CAREFUL;
m_pAVCtx->workaround_bugs = FF_BUG_AUTODETECT;
m_pAVCtx->refcounted_frames = 1;
if (codec == AV_CODEC_ID_H264)
m_pAVCtx->flags2 |= CODEC_FLAG2_SHOW_ALL;
// Setup threading
int thread_type = getThreadFlags(codec);
if (thread_type) {
// Thread Count. 0 = auto detect
int thread_count = m_pSettings->GetNumThreads();
if (thread_count == 0) {
SYSTEM_INFO systemInfo;
GetSystemInfo(&systemInfo);
thread_count = systemInfo.dwNumberOfProcessors * 3 / 2;
}
m_pAVCtx->thread_count = max(1, min(thread_count, AVCODEC_MAX_THREADS));
m_pAVCtx->thread_type = thread_type;
} else {
m_pAVCtx->thread_count = 1;
}
if (dwDecFlags & LAV_VIDEO_DEC_FLAG_NO_MT) {
m_pAVCtx->thread_count = 1;
}
m_pFrame = av_frame_alloc();
CheckPointer(m_pFrame, E_POINTER);
m_h264RandomAccess.SetAVCNALSize(0);
// Process Extradata
BYTE *extra = NULL;
size_t extralen = 0;
getExtraData(*pmt, NULL, &extralen);
BOOL bH264avc = FALSE;
if (extralen > 0) {
DbgLog((LOG_TRACE, 10, L"-> Processing extradata of %d bytes", extralen));
// Reconstruct AVC1 extradata format
if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a','v','c','1') || m_pAVCtx->codec_tag == MAKEFOURCC('A','V','C','1') || m_pAVCtx->codec_tag == MAKEFOURCC('C','C','V','1'))) {
MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->Format();
extralen += 7;
extra = (uint8_t *)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
extra[0] = 1;
extra[1] = (BYTE)mp2vi->dwProfile;
extra[2] = 0;
extra[3] = (BYTE)mp2vi->dwLevel;
extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 2) - 1;
// Actually copy the metadata into our new buffer
size_t actual_len;
getExtraData(*pmt, extra+6, &actual_len);
// Count the number of SPS/PPS in them and set the length
// We'll put them all into one block and add a second block with 0 elements afterwards
// The parsing logic does not care what type they are, it just expects 2 blocks.
//.........这里部分代码省略.........
示例15: close
bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
close();
_fileStream = stream;
// Read in the Smacker header
_header.signature = _fileStream->readUint32BE();
if (_header.signature != MKTAG('S', 'M', 'K', '2') && _header.signature != MKTAG('S', 'M', 'K', '4'))
return false;
uint32 width = _fileStream->readUint32LE();
uint32 height = _fileStream->readUint32LE();
uint32 frameCount = _fileStream->readUint32LE();
int32 frameDelay = _fileStream->readSint32LE();
// frame rate contains 2 digits after the comma, so 1497 is actually 14.97 fps
Common::Rational frameRate;
if (frameDelay > 0)
frameRate = Common::Rational(1000, frameDelay);
else if (frameDelay < 0)
frameRate = Common::Rational(100000, -frameDelay);
else
frameRate = 1000;
// Flags are determined by which bit is set, which can be one of the following:
// 0 - set to 1 if file contains a ring frame.
// 1 - set to 1 if file is Y-interlaced
// 2 - set to 1 if file is Y-doubled
// If bits 1 or 2 are set, the frame should be scaled to twice its height
// before it is displayed.
_header.flags = _fileStream->readUint32LE();
SmackerVideoTrack *videoTrack = createVideoTrack(width, height, frameCount, frameRate, _header.flags, _header.signature);
addTrack(videoTrack);
// TODO: should we do any extra processing for Smacker files with ring frames?
// TODO: should we do any extra processing for Y-doubled videos? Are they the
// same as Y-interlaced videos?
uint32 i;
for (i = 0; i < 7; ++i)
_header.audioSize[i] = _fileStream->readUint32LE();
_header.treesSize = _fileStream->readUint32LE();
_header.mMapSize = _fileStream->readUint32LE();
_header.mClrSize = _fileStream->readUint32LE();
_header.fullSize = _fileStream->readUint32LE();
_header.typeSize = _fileStream->readUint32LE();
for (i = 0; i < 7; ++i) {
// AudioRate - Frequency and format information for each sound track, up to 7 audio tracks.
// The 32 constituent bits have the following meaning:
// * bit 31 - indicates Huffman + DPCM compression
// * bit 30 - indicates that audio data is present for this track
// * bit 29 - 1 = 16-bit audio; 0 = 8-bit audio
// * bit 28 - 1 = stereo audio; 0 = mono audio
// * bit 27 - indicates Bink RDFT compression
// * bit 26 - indicates Bink DCT compression
// * bits 25-24 - unused
// * bits 23-0 - audio sample rate
uint32 audioInfo = _fileStream->readUint32LE();
_header.audioInfo[i].hasAudio = audioInfo & 0x40000000;
_header.audioInfo[i].is16Bits = audioInfo & 0x20000000;
_header.audioInfo[i].isStereo = audioInfo & 0x10000000;
_header.audioInfo[i].sampleRate = audioInfo & 0xFFFFFF;
if (audioInfo & 0x8000000)
_header.audioInfo[i].compression = kCompressionRDFT;
else if (audioInfo & 0x4000000)
_header.audioInfo[i].compression = kCompressionDCT;
else if (audioInfo & 0x80000000)
_header.audioInfo[i].compression = kCompressionDPCM;
else
_header.audioInfo[i].compression = kCompressionNone;
if (_header.audioInfo[i].hasAudio) {
if (_header.audioInfo[i].compression == kCompressionRDFT || _header.audioInfo[i].compression == kCompressionDCT)
warning("Unhandled Smacker v2 audio compression");
addTrack(new SmackerAudioTrack(_header.audioInfo[i], _soundType));
}
}
_header.dummy = _fileStream->readUint32LE();
_frameSizes = new uint32[frameCount];
for (i = 0; i < frameCount; ++i)
_frameSizes[i] = _fileStream->readUint32LE();
_frameTypes = new byte[frameCount];
for (i = 0; i < frameCount; ++i)
_frameTypes[i] = _fileStream->readByte();
byte *huffmanTrees = (byte *) malloc(_header.treesSize);
_fileStream->read(huffmanTrees, _header.treesSize);
Common::BitStream8LSB bs(new Common::MemoryReadStream(huffmanTrees, _header.treesSize, DisposeAfterUse::YES), true);
videoTrack->readTrees(bs, _header.mMapSize, _header.mClrSize, _header.fullSize, _header.typeSize);
//.........这里部分代码省略.........