55 static const char bgr_chlist[4] = {
'B',
'G',
'R',
'A' };
87 uint16_t basetable[512];
153 const ptrdiff_t half_size = (size + 1) / 2;
157 for (ptrdiff_t
i = 0;
i < half_size;
i++) {
167 for (ptrdiff_t
i = 1;
i <
size;
i++) {
168 int d = src[
i] - p + 384;
178 int64_t
i = 0, o = 0,
run = 1,
copy = 0;
180 while (i < in_size) {
181 while (i +
run < in_size && in[i] == in[i +
run] &&
run < 128)
185 if (o + 2 >= out_size)
191 if (i +
run < in_size)
193 while (i +
copy < in_size &&
copy < 127 && in[i +
copy] != in[i +
copy - 1])
196 if (o + 1 +
copy >= out_size)
200 for (
int x = 0; x <
copy; x++)
201 out[o + x] = in[i + x];
218 for (
int y = 0; y < frame->
height; y++) {
221 int64_t max_compressed_size = tmp_size * 3 / 2;
237 for (
int p = 0; p < s->
planes; p++) {
245 for (
int p = 0; p < s->
planes; p++) {
248 uint32_t *
src = (uint32_t *)(frame->
data[ch] + y * frame->
linesize[ch]);
250 for (
int x = 0; x < frame->
width; x++)
260 scanline->
tmp, tmp_size);
280 int64_t max_compressed_size = tmp_size * 3 / 2;
297 for (
int l = 0; l < scanline_height; l++) {
298 const int scanline_size = frame->
width * 4 * s->
planes;
300 for (
int p = 0; p < s->
planes; p++) {
310 for (
int l = 0; l < scanline_height; l++) {
311 const int scanline_size = frame->
width * 2 * s->
planes;
313 for (
int p = 0; p < s->
planes; p++) {
318 for (
int x = 0; x < frame->
width; x++)
328 actual_size = max_compressed_size;
330 scanline->
tmp, source_size);
353 avctx->
height, 64) * 3LL / 2;
360 bytestream2_put_le32(pb, 20000630);
361 bytestream2_put_byte(pb, 2);
362 bytestream2_put_le24(pb, 0);
364 bytestream2_put_le32(pb, s->
planes * 18 + 1);
366 for (
int p = 0; p < s->
planes; p++) {
367 bytestream2_put_byte(pb, s->
ch_names[p]);
368 bytestream2_put_byte(pb, 0);
370 bytestream2_put_le32(pb, 0);
371 bytestream2_put_le32(pb, 1);
372 bytestream2_put_le32(pb, 1);
374 bytestream2_put_byte(pb, 0);
377 bytestream2_put_le32(pb, 1);
381 bytestream2_put_le32(pb, 16);
382 bytestream2_put_le32(pb, 0);
383 bytestream2_put_le32(pb, 0);
384 bytestream2_put_le32(pb, avctx->
width - 1);
385 bytestream2_put_le32(pb, avctx->
height - 1);
388 bytestream2_put_le32(pb, 16);
389 bytestream2_put_le32(pb, 0);
390 bytestream2_put_le32(pb, 0);
391 bytestream2_put_le32(pb, avctx->
width - 1);
392 bytestream2_put_le32(pb, avctx->
height - 1);
395 bytestream2_put_le32(pb, 1);
396 bytestream2_put_byte(pb, 0);
399 bytestream2_put_le32(pb, 8);
400 bytestream2_put_le64(pb, 0);
403 bytestream2_put_le32(pb, 4);
408 bytestream2_put_le32(pb, 4);
414 bytestream2_put_le32(pb, 8);
420 bytestream2_put_le32(pb, 4);
424 bytestream2_put_le32(pb, 4);
426 bytestream2_put_byte(pb, 0);
449 for (
int y = 0; y < avctx->
height; y++) {
450 bytestream2_put_le64(pb, offset);
454 for (
int y = 0; y < avctx->
height; y++) {
455 bytestream2_put_le32(pb, y);
456 bytestream2_put_le32(pb, s->
planes * avctx->
width * 4);
457 for (
int p = 0; p < s->
planes; p++) {
464 for (
int y = 0; y < avctx->
height; y++) {
465 bytestream2_put_le64(pb, offset);
469 for (
int y = 0; y < avctx->
height; y++) {
470 bytestream2_put_le32(pb, y);
471 bytestream2_put_le32(pb, s->
planes * avctx->
width * 2);
472 for (
int p = 0; p < s->
planes; p++) {
474 uint32_t *
src = (uint32_t *)(frame->
data[ch] + y * frame->
linesize[ch]);
476 for (
int x = 0; x < frame->
width; x++)
490 bytestream2_put_le64(pb, offset);
515 #define OFFSET(x) offsetof(EXRContext, x) 516 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 541 .priv_class = &exr_class,
static int encode_scanline_rle(EXRContext *s, const AVFrame *frame)
static void copy(const float *p1, float *p2, const int length)
This structure describes decoded (raw) audio or video data.
#define LIBAVUTIL_VERSION_INT
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
static av_cold int init(AVCodecContext *avctx)
static const uint8_t gbra_order[4]
unsigned int compressed_size
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
unsigned int uncompressed_size
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
enum ExrPixelType pixel_type
static const char bgr_chlist[4]
static const AVClass exr_class
static int64_t rle_compress(uint8_t *out, int64_t out_size, const uint8_t *in, int64_t in_size)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
uint8_t * compressed_data
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static int encode_close(AVCodecContext *avctx)
static const char abgr_chlist[4]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static double av_q2d(AVRational a)
Convert an AVRational to a double.
EXRScanlineData * scanline
static const uint8_t gbr_order[4]
static uint16_t float2half(uint32_t f, uint16_t *basetable, uint8_t *shifttable)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
static const AVOption options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static void reorder_pixels(uint8_t *dst, const uint8_t *src, ptrdiff_t size)
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int flags
A combination of AV_PKT_FLAG values.
static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
static void predictor(uint8_t *src, ptrdiff_t size)
int width
picture width / height.
enum ExrCompr compression
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
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
uint8_t * uncompressed_data
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRAPF32
common internal api header.
static void float2half_tables(uint16_t *basetable, uint8_t *shifttable)
#define FFSWAP(type, a, b)
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 int encode_init(AVCodecContext *avctx)
AVPixelFormat
Pixel format.
This structure stores compressed data.