avcodec: add a ffv1 parser

Only setting frame and stream properties. No packetization is performed.

Signed-off-by: James Almer <jamrial@gmail.com>
master
James Almer 4 weeks ago
parent 3d3ce9647f
commit e504247db6
  1. 1
      Changelog
  2. 1
      configure
  3. 1
      libavcodec/Makefile
  4. 86
      libavcodec/ffv1_parser.c
  5. 1
      libavcodec/parsers.c
  6. 4
      libavcodec/version.h

@ -51,6 +51,7 @@ version 7.1:
and av1_nvenc encoders and av1_nvenc encoders
- libswresample now accepts custom order channel layouts as input, with some - libswresample now accepts custom order channel layouts as input, with some
constrains constrains
- FFV1 parser
version 7.0: version 7.0:

1
configure vendored

@ -3472,6 +3472,7 @@ vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec"
aac_parser_select="adts_header mpeg4audio" aac_parser_select="adts_header mpeg4audio"
av1_parser_select="cbs_av1" av1_parser_select="cbs_av1"
evc_parser_select="evcparse" evc_parser_select="evcparse"
ffv1_parser_select="rangecoder"
ftr_parser_select="adts_header mpeg4audio" ftr_parser_select="adts_header mpeg4audio"
h264_parser_select="golomb h264dsp h264parse h264_sei" h264_parser_select="golomb h264dsp h264parse h264_sei"
hevc_parser_select="hevcparse hevc_sei" hevc_parser_select="hevcparse hevc_sei"

@ -1210,6 +1210,7 @@ OBJS-$(CONFIG_DVBSUB_PARSER) += dvbsub_parser.o
OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o OBJS-$(CONFIG_DVD_NAV_PARSER) += dvd_nav_parser.o
OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o OBJS-$(CONFIG_DVDSUB_PARSER) += dvdsub_parser.o
OBJS-$(CONFIG_EVC_PARSER) += evc_parser.o OBJS-$(CONFIG_EVC_PARSER) += evc_parser.o
OBJS-$(CONFIG_FFV1_PARSER) += ffv1_parser.o ffv1_parse.o ffv1.o
OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
OBJS-$(CONFIG_FTR_PARSER) += ftr_parser.o OBJS-$(CONFIG_FTR_PARSER) += ftr_parser.o
OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o OBJS-$(CONFIG_G723_1_PARSER) += g723_1_parser.o

@ -0,0 +1,86 @@
/*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
#include "ffv1.h"
#include "rangecoder.h"
typedef struct FFV1ParseContext {
FFV1Context f;
int got_first;
} FFV1ParseContext;
static int parse(AVCodecParserContext *s,
AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size)
{
FFV1ParseContext *p = s->priv_data;
FFV1Context *f = &p->f;
RangeCoder c;
uint8_t keystate = 128;
*poutbuf = buf;
*poutbuf_size = buf_size;
if (!p->got_first) {
int ret = ff_ffv1_common_init(avctx, f);
p->got_first = 1;
if (ret < 0)
return buf_size;
if (avctx->extradata_size > 0 && (ret = ff_ffv1_read_extra_header(f)) < 0)
return buf_size;
}
ff_init_range_decoder(&c, buf, buf_size);
ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8);
f->avctx = avctx;
s->key_frame = get_rac(&c, &keystate);
s->pict_type = AV_PICTURE_TYPE_I;
s->field_order = AV_FIELD_UNKNOWN;
s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
if (s->key_frame) {
uint8_t state[CONTEXT_SIZE];
memset(state, 128, sizeof(state));
ff_ffv1_parse_header(f, &c, state);
}
s->width = f->width;
s->height = f->height;
s->format = f->pix_fmt;
return buf_size;
}
static void close(AVCodecParserContext *s)
{
FFV1ParseContext *p = s->priv_data;
p->f.avctx = NULL;
ff_ffv1_close(&p->f);
}
const AVCodecParser ff_ffv1_parser = {
.codec_ids = { AV_CODEC_ID_FFV1 },
.priv_data_size = sizeof(FFV1ParseContext),
.parser_parse = parse,
.parser_close = close,
};

@ -45,6 +45,7 @@ extern const AVCodecParser ff_dvd_nav_parser;
extern const AVCodecParser ff_evc_parser; extern const AVCodecParser ff_evc_parser;
extern const AVCodecParser ff_flac_parser; extern const AVCodecParser ff_flac_parser;
extern const AVCodecParser ff_ftr_parser; extern const AVCodecParser ff_ftr_parser;
extern const AVCodecParser ff_ffv1_parser;
extern const AVCodecParser ff_g723_1_parser; extern const AVCodecParser ff_g723_1_parser;
extern const AVCodecParser ff_g729_parser; extern const AVCodecParser ff_g729_parser;
extern const AVCodecParser ff_gif_parser; extern const AVCodecParser ff_gif_parser;

@ -29,8 +29,8 @@
#include "version_major.h" #include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 32 #define LIBAVCODEC_VERSION_MINOR 33
#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \

Loading…
Cancel
Save