Go to the documentation of this file.
59 s->row_size = (avctx->
width + 7) >> 3;
62 if (ret < 0 || frame_size > INT_MAX) {
64 "Cannot allocate frame buffer for dimensions %dx%d.\n",
72 if (!
s->previous_frame || !
s->work_frame)
79 Z_DEFAULT_COMPRESSION :
108 z_stream *
const zstream = &
s->zstream.zstream;
109 uint8_t *prev =
s->previous_frame;
110 uint8_t *curr =
s->work_frame;
112 const int keyframe =
s->frame_number == 0 || avctx->
gop_size <= 1 ||
113 s->frame_number -
s->last_keyframe >= avctx->
gop_size;
117 if (
s->frame_number == INT_MAX) {
123 const uint8_t *
src =
frame->data[0];
124 const ptrdiff_t src_linesize =
frame->linesize[0];
126 for (
int y = 0; y < avctx->
height; y++) {
127 memcpy(curr + y *
s->row_size,
src,
s->row_size);
139 for (
int i = 0;
i <
s->frame_size;
i++)
144 zret = deflateReset(zstream);
150 zstream->next_in = payload;
151 zstream->avail_in =
s->frame_size;
153 zstream->avail_out =
pkt->
size;
155 zret =
deflate(zstream, Z_FINISH);
156 if (zret != Z_STREAM_END) {
161 pkt->
size = zstream->total_out;
164 s->last_keyframe =
s->frame_number;
167 FFSWAP(uint8_t*,
s->previous_frame,
s->work_frame);
int av_size_mult(size_t a, size_t b, size_t *r)
Multiply two size_t values checking for overflow.
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
const FFCodec ff_pdv_encoder
This structure describes decoded (raw) audio or video data.
void ff_deflate_end(FFZStream *zstream)
Wrapper around deflateEnd().
#define FF_COMPRESSION_DEFAULT
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVCodec p
The public AVCodec.
#define FF_CODEC_ENCODE_CB(func)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
#define i(width, name, range_min, range_max)
#define AVERROR_EXTERNAL
Generic error in an external library.
int flags
A combination of AV_PKT_FLAG values.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define FFSWAP(type, a, b)
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.
static av_cold int encode_init(AVCodecContext *avctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
static av_cold int encode_end(AVCodecContext *avctx)
This structure stores compressed data.
int width
picture width / height.
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...
int ff_deflate_init(FFZStream *zstream, int level, void *logctx)
Wrapper around deflateInit().