"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libavformat/smacker.c" between
libav-12.1.tar.gz and libav-12.2.tar.gz

About: libav provides cross-platform tools ("avconv") and libraries to convert, manipulate and stream a wide range of multimedia (audio and video) formats and protocols.

smacker.c  (libav-12.1):smacker.c  (libav-12.2)
skipping to change at line 114 skipping to change at line 114
{ {
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
SmackerContext *smk = s->priv_data; SmackerContext *smk = s->priv_data;
AVStream *st, *ast[7]; AVStream *st, *ast[7];
int i, ret; int i, ret;
int tbase; int tbase;
/* read and check header */ /* read and check header */
smk->magic = avio_rl32(pb); smk->magic = avio_rl32(pb);
if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4')) if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))
return -1; return AVERROR_INVALIDDATA;
smk->width = avio_rl32(pb); smk->width = avio_rl32(pb);
smk->height = avio_rl32(pb); smk->height = avio_rl32(pb);
smk->frames = avio_rl32(pb); smk->frames = avio_rl32(pb);
smk->pts_inc = (int32_t)avio_rl32(pb); smk->pts_inc = (int32_t)avio_rl32(pb);
if (smk->pts_inc > INT_MAX / 100) {
av_log(s, AV_LOG_ERROR, "pts_inc %d is too large\n", smk->pts_inc);
return AVERROR_INVALIDDATA;
}
smk->flags = avio_rl32(pb); smk->flags = avio_rl32(pb);
if(smk->flags & SMACKER_FLAG_RING_FRAME) if(smk->flags & SMACKER_FLAG_RING_FRAME)
smk->frames++; smk->frames++;
for(i = 0; i < 7; i++) for(i = 0; i < 7; i++)
smk->audio[i] = avio_rl32(pb); smk->audio[i] = avio_rl32(pb);
smk->treesize = avio_rl32(pb); smk->treesize = avio_rl32(pb);
if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (th is check is probably redundant) if(smk->treesize >= UINT_MAX/4){ // smk->treesize + 16 must not overflow (th is check is probably redundant)
av_log(s, AV_LOG_ERROR, "treesize too large\n"); av_log(s, AV_LOG_ERROR, "treesize too large\n");
return -1; return AVERROR_INVALIDDATA;
} }
//FIXME remove extradata "rebuilding" //FIXME remove extradata "rebuilding"
smk->mmap_size = avio_rl32(pb); smk->mmap_size = avio_rl32(pb);
smk->mclr_size = avio_rl32(pb); smk->mclr_size = avio_rl32(pb);
smk->full_size = avio_rl32(pb); smk->full_size = avio_rl32(pb);
smk->type_size = avio_rl32(pb); smk->type_size = avio_rl32(pb);
for(i = 0; i < 7; i++) { for(i = 0; i < 7; i++) {
smk->rates[i] = avio_rl24(pb); smk->rates[i] = avio_rl24(pb);
smk->aflags[i] = avio_r8(pb); smk->aflags[i] = avio_r8(pb);
} }
smk->pad = avio_rl32(pb); smk->pad = avio_rl32(pb);
/* setup data */ /* setup data */
if(smk->frames > 0xFFFFFF) { if(smk->frames > 0xFFFFFF) {
av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames); av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames);
return -1; return AVERROR_INVALIDDATA;
} }
smk->frm_size = av_malloc(smk->frames * 4); smk->frm_size = av_malloc(smk->frames * 4);
smk->frm_flags = av_malloc(smk->frames); smk->frm_flags = av_malloc(smk->frames);
smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2')); smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));
/* read frame info */ /* read frame info */
for(i = 0; i < smk->frames; i++) { for(i = 0; i < smk->frames; i++) {
smk->frm_size[i] = avio_rl32(pb); smk->frm_size[i] = avio_rl32(pb);
} }
for(i = 0; i < smk->frames; i++) { for(i = 0; i < smk->frames; i++) {
smk->frm_flags[i] = avio_r8(pb); smk->frm_flags[i] = avio_r8(pb);
} }
/* init video codec */ /* init video codec */
st = avformat_new_stream(s, NULL); st = avformat_new_stream(s, NULL);
if (!st) if (!st)
return -1; return AVERROR(ENOMEM);
smk->videoindex = st->index; smk->videoindex = st->index;
st->codecpar->width = smk->width; st->codecpar->width = smk->width;
st->codecpar->height = smk->height; st->codecpar->height = smk->height;
st->codecpar->format = AV_PIX_FMT_PAL8; st->codecpar->format = AV_PIX_FMT_PAL8;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_SMACKVIDEO; st->codecpar->codec_id = AV_CODEC_ID_SMACKVIDEO;
st->codecpar->codec_tag = smk->magic; st->codecpar->codec_tag = smk->magic;
/* Smacker uses 100000 as internal timebase */ /* Smacker uses 100000 as internal timebase */
if(smk->pts_inc < 0) if(smk->pts_inc < 0)
smk->pts_inc = -smk->pts_inc; smk->pts_inc = -smk->pts_inc;
skipping to change at line 222 skipping to change at line 227
/* load trees to extradata, they will be unpacked by decoder */ /* load trees to extradata, they will be unpacked by decoder */
st->codecpar->extradata = av_mallocz(smk->treesize + 16 + st->codecpar->extradata = av_mallocz(smk->treesize + 16 +
AV_INPUT_BUFFER_PADDING_SIZE); AV_INPUT_BUFFER_PADDING_SIZE);
st->codecpar->extradata_size = smk->treesize + 16; st->codecpar->extradata_size = smk->treesize + 16;
if (!st->codecpar->extradata) { if (!st->codecpar->extradata) {
av_log(s, AV_LOG_ERROR, av_log(s, AV_LOG_ERROR,
"Cannot allocate %"PRIu32" bytes of extradata\n", "Cannot allocate %"PRIu32" bytes of extradata\n",
smk->treesize + 16); smk->treesize + 16);
av_free(smk->frm_size); av_free(smk->frm_size);
av_free(smk->frm_flags); av_free(smk->frm_flags);
return -1; return AVERROR(ENOMEM);
} }
ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_si ze - 16); ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_si ze - 16);
if(ret != st->codecpar->extradata_size - 16){ if(ret != st->codecpar->extradata_size - 16){
av_free(smk->frm_size); av_free(smk->frm_size);
av_free(smk->frm_flags); av_free(smk->frm_flags);
return AVERROR(EIO); return AVERROR(EIO);
} }
((int32_t*)st->codecpar->extradata)[0] = av_le2ne32(smk->mmap_size); ((int32_t*)st->codecpar->extradata)[0] = av_le2ne32(smk->mmap_size);
((int32_t*)st->codecpar->extradata)[1] = av_le2ne32(smk->mclr_size); ((int32_t*)st->codecpar->extradata)[1] = av_le2ne32(smk->mclr_size);
((int32_t*)st->codecpar->extradata)[2] = av_le2ne32(smk->full_size); ((int32_t*)st->codecpar->extradata)[2] = av_le2ne32(smk->full_size);
 End of changes. 6 change blocks. 
5 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)