53 s->row_size = (avctx->
width + 7) >> 3;
55 s->frame_size =
s->row_size * avctx->
height;
59 if (!
s->previous_frame || !
s->work_frame)
66 Z_DEFAULT_COMPRESSION :
86 z_stream *
const zstream = &
s->zstream.zstream;
87 uint8_t *prev =
s->previous_frame;
88 uint8_t *curr =
s->work_frame;
90 const int keyframe =
s->frame_number == 0 || avctx->
gop_size <= 1 ||
91 s->frame_number -
s->last_keyframe >= avctx->
gop_size;
95 if (
s->frame_number == INT_MAX) {
101 const uint8_t *
src =
frame->data[0];
102 const ptrdiff_t src_linesize =
frame->linesize[0];
104 for (
int y = 0; y < avctx->
height; y++) {
105 memcpy(curr + y *
s->row_size,
src,
s->row_size);
117 for (
int i = 0;
i <
s->frame_size;
i++)
122 zret = deflateReset(zstream);
128 zstream->next_in = payload;
129 zstream->avail_in =
s->frame_size;
130 zstream->next_out =
pkt->data;
131 zstream->avail_out =
pkt->size;
133 zret =
deflate(zstream, Z_FINISH);
134 if (zret != Z_STREAM_END) {
139 pkt->size = zstream->total_out;
142 s->last_keyframe =
s->frame_number;
145 FFSWAP(uint8_t*,
s->previous_frame,
s->work_frame);
const FFCodec ff_pdv_encoder
static av_cold int encode_init(AVCodecContext *avctx)
Libavcodec external API header.
#define FF_COMPRESSION_DEFAULT
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
static av_cold int encode_end(AVCodecContext *avctx)
static av_cold int encode_init(AVCodecContext *avctx)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static av_cold int encode_end(AVCodecContext *avctx)
#define FFSWAP(type, a, b)
Memory handling functions.
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
main external API structure.
int width
picture width / height.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
int ff_deflate_init(FFZStream *zstream, int level, void *logctx)
Wrapper around deflateInit().
void ff_deflate_end(FFZStream *zstream)
Wrapper around deflateEnd().