Go to the documentation of this file.
70 int h,
int w,
int stride, uint8_t *pfptr)
77 for (
i = dx +
h;
i > dx;
i--) {
78 nsptr = sptr +
i *
stride + dy * 3;
79 npfptr = pfptr +
i *
stride + dy * 3;
80 for (j = 0; j <
w * 3; j++) {
81 diff |= npfptr[j] ^ nsptr[j];
109 "Input dimensions too large, input must be max 4095x4095 !\n");
113 s->last_key_frame = 0;
115 s->image_width = avctx->
width;
116 s->image_height = avctx->
height;
118 s->encbuffer =
av_mallocz(
s->image_width *
s->image_height * 3);
130 int buf_size,
int block_width,
int block_height,
131 uint8_t *previous_frame,
int *I_frame)
135 int h_blocks, v_blocks, h_part, v_part,
i, j;
141 put_bits(&pb, 4, block_width / 16 - 1);
143 put_bits(&pb, 4, block_height / 16 - 1);
148 h_blocks =
s->image_width / block_width;
149 h_part =
s->image_width % block_width;
150 v_blocks =
s->image_height / block_height;
151 v_part =
s->image_height % block_height;
154 for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) {
156 int y_pos = j * block_height;
157 int cur_blk_height = (j < v_blocks) ? block_height : v_part;
160 for (
i = 0;
i < h_blocks + (h_part ? 1 : 0);
i++) {
161 int x_pos =
i * block_width;
162 int cur_blk_width = (
i < h_blocks) ? block_width : h_part;
164 uint8_t *ptr = buf + buf_pos;
169 s->image_height - (y_pos + cur_blk_height + 1),
170 x_pos, cur_blk_height, cur_blk_width,
173 if (res || *I_frame) {
174 unsigned long zsize = 3 * block_width * block_height;
175 ret = compress2(ptr + 2, &zsize,
s->tmpblock,
176 3 * cur_blk_width * cur_blk_height, 9);
180 "error while compressing block %dx%d\n",
i, j);
182 bytestream_put_be16(&ptr, zsize);
183 buf_pos += zsize + 2;
184 ff_dlog(
s->avctx,
"buf_pos = %d\n", buf_pos);
187 bytestream_put_be16(&ptr, 0);
203 const AVFrame *pict,
int *got_packet)
206 const AVFrame *
const p = pict;
210 int opt_w = 4, opt_h = 4;
215 if (!
s->previous_frame) {
223 pfptr =
s->previous_frame - (
s->image_height - 1) * p->
linesize[0];
225 pfptr =
s->previous_frame;
241 memcpy(
s->previous_frame, p->
data[0],
s->image_height * p->
linesize[0]);
243 memcpy(
s->previous_frame,
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVPixelFormat
Pixel format.
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
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static enum AVPixelFormat pix_fmts[]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy, int h, int w, int stride, uint8_t *pfptr)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
static av_cold int flashsv_encode_init(AVCodecContext *avctx)
int flags
A combination of AV_PKT_FLAG values.
#define i(width, name, range_min, range_max)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static av_cold int flashsv_encode_end(AVCodecContext *avctx)
main external API structure.
int frame_number
Frame counter, set by libavcodec.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
const AVCodec ff_flashsv_encoder
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)