36 #define MAKE_WRITABLE(table) \
39 (ret = av_buffer_make_writable(&pic->table)) < 0)\
50 for (
i = 0;
i < 2;
i++) {
61 # define EMU_EDGE_HEIGHT (4 * 70)
87 me->temp =
me->scratchpad;
100 int chroma_x_shift,
int chroma_y_shift,
101 int linesize,
int uvlinesize)
124 if (r < 0 || !pic->
f->buf[0]) {
147 av_log(avctx,
AV_LOG_ERROR,
"alloc_frame_buffer() failed (hwaccel private data allocation)\n");
154 if ((linesize && linesize != pic->
f->
linesize[0]) ||
155 (uvlinesize && uvlinesize != pic->
f->
linesize[1])) {
157 "get_buffer() failed (stride changed: linesize=%d/%d uvlinesize=%d/%d)\n",
167 "get_buffer() failed (uv stride mismatch)\n");
176 "get_buffer() failed to allocate context scratch buffers.\n");
185 int mb_stride,
int mb_width,
int mb_height,
int b8_stride)
187 const int big_mb_num = mb_stride * (mb_height + 1) + 1;
188 const int mb_array_size = mb_stride * mb_height;
189 const int b8_array_size = b8_stride * mb_height * 2;
208 if (out_format ==
FMT_H263 || encoding ||
210 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
211 int ref_index_size = 4 * mb_array_size;
213 for (
i = 0; mv_size &&
i < 2;
i++) {
234 int chroma_x_shift,
int chroma_y_shift,
int out_format,
235 int mb_stride,
int mb_width,
int mb_height,
int b8_stride,
236 ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
251 chroma_x_shift, chroma_y_shift,
252 *linesize, *uvlinesize) < 0)
261 mb_stride, mb_width, mb_height, b8_stride);
278 for (
i = 0;
i < 2;
i++) {
314 memset((
uint8_t*)pic + off, 0,
sizeof(*pic) - off);
327 for (
i = 0;
i < 2;
i++) {
343 for (
i = 0;
i < 2;
i++) {
372 if (
src->hwaccel_picture_private) {
413 if (!picture[
i].
f->buf[0])
424 "Internal error, picture buffer overflow\n");
445 if (picture[ret].needs_realloc) {
468 for (
i = 0;
i < 2;
i++) {
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int av_codec_is_encoder(const AVCodec *codec)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_EXPORT_DATA_MVS
Export motion vectors through frame side data.
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_allocz(buffer_size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src)
Ensure dst refers to the same data as src.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output.
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
static int pic_is_unused(Picture *pic)
static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, ScratchpadContext *sc, int chroma_x_shift, int chroma_y_shift, int linesize, int uvlinesize)
Allocate a frame buffer.
int ff_alloc_picture(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, ScratchpadContext *sc, int shared, int encoding, int chroma_x_shift, int chroma_y_shift, int out_format, int mb_stride, int mb_width, int mb_height, int b8_stride, ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
Allocate a Picture.
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
Deallocate a picture.
int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src)
static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
#define MAKE_WRITABLE(table)
int ff_update_picture_tables(Picture *dst, Picture *src)
static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format, int mb_stride, int mb_width, int mb_height, int b8_stride)
static int make_tables_writable(Picture *pic)
void ff_free_picture_tables(Picture *pic)
int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, ScratchpadContext *sc, int linesize)
#define MAX_PICTURE_COUNT
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
uint8_t * data
The data buffer.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int64_t max_pixels
The number of pixels per image to maximally accept.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
const struct AVCodec * codec
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
Motion estimation context.
int16_t(*[2] motion_val)[2]
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
AVBufferRef * ref_index_buf[2]
AVBufferRef * mbskip_table_buf
AVBufferRef * qscale_table_buf
uint64_t encoding_error[AV_NUM_DATA_POINTERS]
uint8_t * mb_mean
Table for MB luminance.
int64_t mc_mb_var_sum
motion compensated MB variance for current frame
uint16_t * mc_mb_var
Table for motion compensated MB variances.
uint16_t * mb_var
Table for MB variances.
AVBufferRef * mb_mean_buf
AVBufferRef * mc_mb_var_buf
AVBufferRef * hwaccel_priv_buf
int alloc_mb_stride
mb_stride used to allocate tables
AVBufferRef * mb_type_buf
void * hwaccel_picture_private
Hardware accelerator private data.
AVBufferRef * motion_val_buf[2]
int alloc_mb_width
mb_width used to allocate tables
uint32_t * mb_type
types and macros are defined in mpegutils.h
int64_t mb_var_sum
sum of MB variance for current frame
int alloc_mb_height
mb_height used to allocate tables
int field_picture
whether or not the picture was encoded in separate fields
uint8_t * b_scratchpad
scratchpad used for writing into write only buffers
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
uint8_t * obmc_scratchpad
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
static const uint8_t offset[127][2]