76 for (
i = dx +
h;
i > dx;
i--) {
77 nsptr = sptr +
i *
stride + dy * 3;
78 npfptr = pfptr +
i *
stride + dy * 3;
79 for (j = 0; j <
w * 3; j++) {
80 diff |= npfptr[j] ^ nsptr[j];
108 "Input dimensions too large, input must be max 4095x4095 !\n");
112 s->last_key_frame = 0;
114 s->image_width = avctx->
width;
115 s->image_height = avctx->
height;
117 s->encbuffer =
av_mallocz(
s->image_width *
s->image_height * 3);
129 int buf_size,
int block_width,
int block_height,
130 uint8_t *previous_frame,
int *I_frame)
134 int h_blocks, v_blocks, h_part, v_part,
i, j;
140 put_bits(&pb, 4, block_width / 16 - 1);
142 put_bits(&pb, 4, block_height / 16 - 1);
147 h_blocks =
s->image_width / block_width;
148 h_part =
s->image_width % block_width;
149 v_blocks =
s->image_height / block_height;
150 v_part =
s->image_height % block_height;
153 for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) {
155 int y_pos = j * block_height;
156 int cur_blk_height = (j < v_blocks) ? block_height : v_part;
159 for (
i = 0;
i < h_blocks + (h_part ? 1 : 0);
i++) {
160 int x_pos =
i * block_width;
161 int cur_blk_width = (
i < h_blocks) ? block_width : h_part;
168 s->image_height - (y_pos + cur_blk_height + 1),
169 x_pos, cur_blk_height, cur_blk_width,
172 if (res || *I_frame) {
173 unsigned long zsize = 3 * block_width * block_height;
174 ret = compress2(ptr + 2, &zsize,
s->tmpblock,
175 3 * cur_blk_width * cur_blk_height, 9);
179 "error while compressing block %dx%d\n",
i, j);
181 bytestream_put_be16(&ptr, zsize);
182 buf_pos += zsize + 2;
183 ff_dlog(
s->avctx,
"buf_pos = %d\n", buf_pos);
186 bytestream_put_be16(&ptr, 0);
202 const AVFrame *pict,
int *got_packet)
205 const AVFrame *
const p = pict;
209 int opt_w = 4, opt_h = 4;
214 if (!
s->previous_frame) {
222 pfptr =
s->previous_frame - (
s->image_height - 1) * p->
linesize[0];
224 pfptr =
s->previous_frame;
240 memcpy(
s->previous_frame, p->
data[0],
s->image_height * p->
linesize[0]);
242 memcpy(
s->previous_frame,
248 #if FF_API_CODED_FRAME
257 #if FF_API_CODED_FRAME
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static av_cold int flashsv_encode_end(AVCodecContext *avctx)
static int encode_bitstream(FlashSVContext *s, const AVFrame *p, uint8_t *buf, int buf_size, int block_width, int block_height, uint8_t *previous_frame, int *I_frame)
static av_cold int flashsv_encode_init(AVCodecContext *avctx)
static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, int h, int w, int stride, uint8_t *pfptr)
AVCodec ff_flashsv_encoder
static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static enum AVPixelFormat pix_fmts[]
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
main external API structure.
int width
picture width / height.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int frame_number
Frame counter, set by libavcodec.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
static av_always_inline int diff(const uint32_t a, const uint32_t b)