X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ffrmdec.c;h=1bc3a83e11bf3cf06edeac6d852a477b17fecf93;hb=930391e5988abe126d29c5e9b09fab459e0b8936;hp=2f6b7264279081859603b6ee3a59a324240e32d4;hpb=1f1ec958f6c68a5ceafea206a99c895f62d0f3ec;p=ffmpeg diff --git a/libavformat/frmdec.c b/libavformat/frmdec.c index 2f6b7264279..1bc3a83e11b 100644 --- a/libavformat/frmdec.c +++ b/libavformat/frmdec.c @@ -29,20 +29,19 @@ #include "libavutil/intreadwrite.h" #include "avformat.h" -static const PixelFormatTag frm_pix_fmt_tags[] = { - { AV_PIX_FMT_RGB555, 1 }, - { AV_PIX_FMT_RGB0, 2 }, - { AV_PIX_FMT_RGB24, 3 }, - { AV_PIX_FMT_BGR0, 4 }, - { AV_PIX_FMT_BGRA, 5 }, - { AV_PIX_FMT_NONE, 0 }, +static const enum AVPixelFormat frm_pix_fmt_tags[] = { + AV_PIX_FMT_RGB555, + AV_PIX_FMT_RGB0, + AV_PIX_FMT_RGB24, + AV_PIX_FMT_BGR0, + AV_PIX_FMT_BGRA, }; typedef struct { int count; } FrmContext; -static int frm_read_probe(AVProbeData *p) +static int frm_read_probe(const AVProbeData *p) { if (p->buf_size > 8 && p->buf[0] == 'F' && p->buf[1] == 'R' && p->buf[2] == 'M' && @@ -55,6 +54,8 @@ static int frm_read_header(AVFormatContext *avctx) { AVIOContext *pb = avctx->pb; AVStream *st = avformat_new_stream(avctx, 0); + unsigned idx; + if (!st) return AVERROR(ENOMEM); @@ -62,9 +63,10 @@ static int frm_read_header(AVFormatContext *avctx) st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; avio_skip(pb, 3); - st->codecpar->format = avpriv_find_pix_fmt(frm_pix_fmt_tags, avio_r8(pb)); - if (!st->codecpar->format) + idx = avio_r8(pb) - 1; + if (idx >= FF_ARRAY_ELEMS(frm_pix_fmt_tags)) return AVERROR_INVALIDDATA; + st->codecpar->format = frm_pix_fmt_tags[idx]; st->codecpar->codec_tag = 0; st->codecpar->width = avio_rl16(pb);