34 #define MAKE_WRITABLE(table) \ 37 (ret = av_buffer_make_writable(&pic->table)) < 0)\ 48 for (i = 0; i < 2; i++) {
87 int chroma_x_shift,
int chroma_y_shift,
88 int linesize,
int uvlinesize)
111 if (r < 0 || !pic->f->buf[0]) {
119 for (i = 0; pic->
f->
data[i]; i++) {
120 int offset = (
EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *
123 pic->
f->
data[i] += offset;
134 av_log(avctx,
AV_LOG_ERROR,
"alloc_frame_buffer() failed (hwaccel private data allocation)\n");
141 if (linesize && (linesize != pic->
f->
linesize[0] ||
144 "get_buffer() failed (stride changed)\n");
151 "get_buffer() failed (uv stride mismatch)\n");
160 "get_buffer() failed to allocate context scratch buffers.\n");
169 int mb_stride,
int mb_height,
int b8_stride)
171 const int big_mb_num = mb_stride * (mb_height + 1) + 1;
172 const int mb_array_size = mb_stride * mb_height;
173 const int b8_array_size = b8_stride * mb_height * 2;
192 if (out_format ==
FMT_H263 || encoding) {
193 int mv_size = 2 * (b8_array_size + 4) *
sizeof(int16_t);
194 int ref_index_size = 4 * mb_array_size;
196 for (i = 0; mv_size && i < 2; i++) {
213 int chroma_x_shift,
int chroma_y_shift,
int out_format,
214 int mb_stride,
int mb_height,
int b8_stride,
215 ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
220 assert(pic->
f->
data[0]);
223 assert(!pic->
f->
buf[0]);
225 chroma_x_shift, chroma_y_shift,
226 *linesize, *uvlinesize) < 0)
235 mb_stride, mb_height, b8_stride);
252 for (i = 0; i < 2; i++) {
291 #define UPDATE_TABLE(table) \ 294 (!dst->table || dst->table->buffer != src->table->buffer)) { \ 295 av_buffer_unref(&dst->table); \ 296 dst->table = av_buffer_ref(src->table); \ 298 ff_free_picture_tables(dst); \ 299 return AVERROR(ENOMEM); \ 310 for (i = 0; i < 2; i++) {
321 for (i = 0; i < 2; i++) {
385 if (!picture[i].f->buf[0])
403 if (picture[ret].needs_realloc) {
423 for (i = 0; i < 2; i++) {
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free.
const struct AVCodec * codec
static int alloc_picture_tables(Picture *pic, int encoding, int out_format, int mb_stride, int mb_height, int b8_stride)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
uint8_t * mb_mean
Table for MB luminance.
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
uint16_t * mb_var
Table for MB variances.
static int pic_is_unused(Picture *pic)
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int field_picture
whether or not the picture was encoded in separate fields
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int find_unused_picture(Picture *picture, int shared)
int av_codec_is_encoder(const AVCodec *codec)
struct AVHWAccel * hwaccel
Hardware accelerator in use.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int make_tables_writable(Picture *pic)
Motion estimation context.
void ff_free_picture_tables(Picture *pic)
int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
AVBufferRef * mb_type_buf
#define UPDATE_TABLE(table)
AVBufferRef * mb_mean_buf
uint64_t encoding_error[4]
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
#define MAX_PICTURE_COUNT
simple assert() macros that are a bit more flexible than ISO C assert().
AVBufferRef * hwaccel_priv_buf
AVBufferRef * motion_val_buf[2]
int width
picture width / height.
int16_t(*[2] motion_val)[2]
void * hwaccel_picture_private
Hardware accelerator private data.
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
if(ac->has_optimized_func)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
uint16_t * mc_mb_var
Table for motion compensated MB variances.
AVBufferRef * qscale_table_buf
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
Libavcodec external API header.
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_height, int b8_stride, ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
Allocate a Picture.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
uint8_t * data
The data buffer.
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, ScratchpadContext *sc, int linesize)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
Deallocate a picture.
#define MAKE_WRITABLE(table)
common internal and external API header
AVBufferRef * mbskip_table_buf
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
uint8_t * b_scratchpad
scratchpad used for writing into write only buffers
int ff_update_picture_tables(Picture *dst, Picture *src)
uint8_t * obmc_scratchpad
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
AVBufferRef * mc_mb_var_buf
int mb_var_sum
sum of MB variance for current frame
int mc_mb_var_sum
motion compensated MB variance for current frame
uint32_t * mb_type
types and macros are defined in mpegutils.h
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
AVBufferRef * ref_index_buf[2]