Go to the documentation of this file.
40 static 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;
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);
142 ctx->pix_fmt =
c->
p.
pix_fmts[bytestream2_get_byte(&gbc) % npixfmts];
147 int coder = bytestream2_get_byte(&gbc)&3;
148 if (coder == 3) coder = -2;
156 ctx->width =
ctx->height = 64;
168 if (!
frame || !avpkt)
169 error(
"Failed memory allocation");
176 ec_pixels += (
ctx->width + 32LL) * (
ctx->height + 32LL);
177 if (ec_pixels > maxpixels)
178 goto maximums_reached;
182 error(
"Failed av_frame_get_buffer");
188 memset(
frame->buf[
i]->data + buf_size, 0,
frame->buf[
i]->size - buf_size);
193 frame->pts = nb_samples;
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
void av_force_cpu_flags(int arg)
Disables cpu detection and forces the specified flags.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int strict_std_compliance
Allow non-standard and experimental extension.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
static void error(const char *err)
AVCodec p
The public AVCodec.
const FFCodec * codec_list[]
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
#define FF_ARRAY_ELEMS(a)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
const uint32_t maxiteration
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
#define ENCODER_SYMBOL(CODEC)
attribute_deprecated enum AVPixelFormat * pix_fmts
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
void av_log_set_level(int level)
Set the log level.
#define i(width, name, range_min, range_max)
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
main external API structure.
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.
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s it
This structure stores compressed data.
static int encode(AVCodecContext *enc_ctx, AVFrame *frame, AVPacket *pkt)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
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...