Skip to content

Commit

Permalink
Merge commit '0539d84d985e811e5989ef27c13f7e2dda0f9b89'
Browse files Browse the repository at this point in the history
* commit '0539d84d985e811e5989ef27c13f7e2dda0f9b89':
  asfdec: Account for different Format Data sizes

See 76853a3

Merged-by: James Almer <[email protected]>
  • Loading branch information
jamrial committed Sep 28, 2017
2 parents e2a5fa1 + 0539d84 commit 42f27d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 7 additions & 5 deletions libavformat/asfdec_o.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,20 +691,22 @@ static int asf_read_properties(AVFormatContext *s, const GUIDParseTable *g)

static int parse_video_info(AVIOContext *pb, AVStream *st)
{
uint16_t size;
uint16_t size_asf; // ASF-specific Format Data size
uint32_t size_bmp; // BMP_HEADER-specific Format Data size
unsigned int tag;

st->codecpar->width = avio_rl32(pb);
st->codecpar->height = avio_rl32(pb);
avio_skip(pb, 1); // skip reserved flags
size = avio_rl16(pb); // size of the Format Data
tag = ff_get_bmp_header(pb, st, NULL);
size_asf = avio_rl16(pb);
tag = ff_get_bmp_header(pb, st, &size_bmp);
st->codecpar->codec_tag = tag;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
size_bmp = FFMAX(size_asf, size_bmp);

if (size > BMP_HEADER_SIZE) {
if (size_bmp > BMP_HEADER_SIZE) {
int ret;
st->codecpar->extradata_size = size - BMP_HEADER_SIZE;
st->codecpar->extradata_size = size_bmp - BMP_HEADER_SIZE;
if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE))) {
st->codecpar->extradata_size = 0;
Expand Down
3 changes: 2 additions & 1 deletion libavformat/riff.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ void ff_end_tag(AVIOContext *pb, int64_t start);
/**
* Read BITMAPINFOHEADER structure and set AVStream codec width, height and
* bits_per_encoded_sample fields. Does not read extradata.
* Writes the size of the BMP file to *size.
* @return codec tag
*/
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize);
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size);

void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int ignore_extradata);

Expand Down
7 changes: 4 additions & 3 deletions libavformat/riffdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps)
return id;
}

int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
int ff_get_bmp_header(AVIOContext *pb, AVStream *st, uint32_t *size)
{
int tag1;
if(esize) *esize = avio_rl32(pb);
else avio_rl32(pb);
uint32_t size_ = avio_rl32(pb);
if (size)
*size = size_;
st->codecpar->width = avio_rl32(pb);
st->codecpar->height = (int32_t)avio_rl32(pb);
avio_rl16(pb); /* planes */
Expand Down

0 comments on commit 42f27d1

Please sign in to comment.