40static void error(
const char *err)
42 fprintf(stderr,
"%s", err);
74 uint64_t maxpixels_per_frame = 512 * 512;
79 uint64_t nb_samples = 0;
81 uint64_t ec_pixels = 0;
84#define ENCODER_SYMBOL0(CODEC) ff_##CODEC##_encoder
85#define ENCODER_SYMBOL(CODEC) ENCODER_SYMBOL0(CODEC)
102 maxpixels_per_frame =
FFMIN(maxpixels_per_frame , maxpixels);
106 error(
"Failed memory allocation");
108 if (
ctx->max_pixels == 0 ||
ctx->max_pixels > maxpixels_per_frame)
109 ctx->max_pixels = maxpixels_per_frame;
119 ctx->width = bytestream2_get_le32(&gbc) & 0xFFFF;
120 ctx->height = bytestream2_get_le32(&gbc) & 0xFFFF;
121 ctx->bit_rate = bytestream2_get_le64(&gbc);
122 ctx->gop_size = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
123 ctx->max_b_frames = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
124 ctx->time_base.num = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
125 ctx->time_base.den = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
126 ctx->framerate.num = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
127 ctx->framerate.den = bytestream2_get_le32(&gbc) & 0x7FFFFFFF;
129 flags = bytestream2_get_byte(&gbc);
136 flags64 = bytestream2_get_le64(&gbc);
143 if (res >= 0 && pix_fmts_num > 0)
144 ctx->pix_fmt =
pix_fmts[bytestream2_get_byte(&gbc) % pix_fmts_num];
148 int coder = bytestream2_get_byte(&gbc)&3;
149 if (coder == 3) coder = -2;
157 ctx->width =
ctx->height = 64;
169 if (!
frame || !avpkt)
170 error(
"Failed memory allocation");
177 ec_pixels += (
ctx->width + 32LL) * (
ctx->height + 32LL);
178 if (ec_pixels > maxpixels)
179 goto maximums_reached;
183 error(
"Failed av_frame_get_buffer");
189 memset(
frame->buf[
i]->data + buf_size, 0,
frame->buf[
i]->size - buf_size);
194 frame->pts = nb_samples;
static AVFormatContext * ctx
static AVDictionary * opts
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
int avcodec_get_supported_config(const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
Retrieve a list of all supported values for a given configuration type.
@ AV_CODEC_CONFIG_PIX_FORMAT
AVPixelFormat, terminated by AV_PIX_FMT_NONE.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
void av_log_set_level(int level)
Set the log level.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_ARRAY_ELEMS(a)
main external API structure.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
const uint32_t maxiteration
const FFCodec * codec_list[]
#define ENCODER_SYMBOL(CODEC)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
static void error(const char *err)
static int encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt)