FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mpegpicture.c
Go to the documentation of this file.
1 /*
2  * Mpeg video formats-related picture management functions
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 
23 #include "libavutil/avassert.h"
24 #include "libavutil/common.h"
25 
26 #include "avcodec.h"
27 #include "motion_est.h"
28 #include "mpegpicture.h"
29 #include "mpegutils.h"
30 
31 static int make_tables_writable(Picture *pic)
32 {
33  int ret, i;
34 #define MAKE_WRITABLE(table) \
35 do {\
36  if (pic->table &&\
37  (ret = av_buffer_make_writable(&pic->table)) < 0)\
38  return ret;\
39 } while (0)
40 
41  MAKE_WRITABLE(mb_var_buf);
42  MAKE_WRITABLE(mc_mb_var_buf);
43  MAKE_WRITABLE(mb_mean_buf);
44  MAKE_WRITABLE(mbskip_table_buf);
45  MAKE_WRITABLE(qscale_table_buf);
46  MAKE_WRITABLE(mb_type_buf);
47 
48  for (i = 0; i < 2; i++) {
49  MAKE_WRITABLE(motion_val_buf[i]);
50  MAKE_WRITABLE(ref_index_buf[i]);
51  }
52 
53  return 0;
54 }
55 
57  ScratchpadContext *sc, int linesize)
58 {
59  int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
60 
61  if (avctx->hwaccel
64 #endif
65  )
66  return 0;
67 
68  if (linesize < 24) {
69  av_log(avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n");
70  return AVERROR_PATCHWELCOME;
71  }
72 
73  // edge emu needs blocksize + filter length - 1
74  // (= 17x17 for halfpel / 21x21 for H.264)
75  // VC-1 computes luma and chroma simultaneously and needs 19X19 + 9x9
76  // at uvlinesize. It supports only YUV420 so 24x24 is enough
77  // linesize * interlaced * MBsize
78  // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
79  FF_ALLOCZ_ARRAY_OR_GOTO(avctx, sc->edge_emu_buffer, alloc_size, 4 * 70,
80  fail);
81 
82  FF_ALLOCZ_ARRAY_OR_GOTO(avctx, me->scratchpad, alloc_size, 4 * 16 * 2,
83  fail)
84  me->temp = me->scratchpad;
85  sc->rd_scratchpad = me->scratchpad;
86  sc->b_scratchpad = me->scratchpad;
87  sc->obmc_scratchpad = me->scratchpad + 16;
88 
89  return 0;
90 fail:
92  return AVERROR(ENOMEM);
93 }
94 
95 /**
96  * Allocate a frame buffer
97  */
98 static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,
100  int chroma_x_shift, int chroma_y_shift,
101  int linesize, int uvlinesize)
102 {
103  int edges_needed = av_codec_is_encoder(avctx->codec);
104  int r, ret;
105 
106  pic->tf.f = pic->f;
107  if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
108  avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
109  avctx->codec_id != AV_CODEC_ID_MSS2) {
110  if (edges_needed) {
111  pic->f->width = avctx->width + 2 * EDGE_WIDTH;
112  pic->f->height = avctx->height + 2 * EDGE_WIDTH;
113  }
114 
115  r = ff_thread_get_buffer(avctx, &pic->tf,
116  pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
117  } else {
118  pic->f->width = avctx->width;
119  pic->f->height = avctx->height;
120  pic->f->format = avctx->pix_fmt;
121  r = avcodec_default_get_buffer2(avctx, pic->f, 0);
122  }
123 
124  if (r < 0 || !pic->f->buf[0]) {
125  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
126  r, pic->f->data[0]);
127  return -1;
128  }
129 
130  if (edges_needed) {
131  int i;
132  for (i = 0; pic->f->data[i]; i++) {
133  int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *
134  pic->f->linesize[i] +
135  (EDGE_WIDTH >> (i ? chroma_x_shift : 0));
136  pic->f->data[i] += offset;
137  }
138  pic->f->width = avctx->width;
139  pic->f->height = avctx->height;
140  }
141 
142  if (avctx->hwaccel) {
143  assert(!pic->hwaccel_picture_private);
144  if (avctx->hwaccel->frame_priv_data_size) {
146  if (!pic->hwaccel_priv_buf) {
147  av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
148  return -1;
149  }
151  }
152  }
153 
154  if (linesize && (linesize != pic->f->linesize[0] ||
155  uvlinesize != pic->f->linesize[1])) {
156  av_log(avctx, AV_LOG_ERROR,
157  "get_buffer() failed (stride changed)\n");
158  ff_mpeg_unref_picture(avctx, pic);
159  return -1;
160  }
161 
162  if (pic->f->linesize[1] != pic->f->linesize[2]) {
163  av_log(avctx, AV_LOG_ERROR,
164  "get_buffer() failed (uv stride mismatch)\n");
165  ff_mpeg_unref_picture(avctx, pic);
166  return -1;
167  }
168 
169  if (!sc->edge_emu_buffer &&
170  (ret = ff_mpeg_framesize_alloc(avctx, me, sc,
171  pic->f->linesize[0])) < 0) {
172  av_log(avctx, AV_LOG_ERROR,
173  "get_buffer() failed to allocate context scratch buffers.\n");
174  ff_mpeg_unref_picture(avctx, pic);
175  return ret;
176  }
177 
178  return 0;
179 }
180 
181 static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format,
182  int mb_stride, int mb_width, int mb_height, int b8_stride)
183 {
184  const int big_mb_num = mb_stride * (mb_height + 1) + 1;
185  const int mb_array_size = mb_stride * mb_height;
186  const int b8_array_size = b8_stride * mb_height * 2;
187  int i;
188 
189 
190  pic->mbskip_table_buf = av_buffer_allocz(mb_array_size + 2);
191  pic->qscale_table_buf = av_buffer_allocz(big_mb_num + mb_stride);
192  pic->mb_type_buf = av_buffer_allocz((big_mb_num + mb_stride) *
193  sizeof(uint32_t));
194  if (!pic->mbskip_table_buf || !pic->qscale_table_buf || !pic->mb_type_buf)
195  return AVERROR(ENOMEM);
196 
197  if (encoding) {
198  pic->mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t));
199  pic->mc_mb_var_buf = av_buffer_allocz(mb_array_size * sizeof(int16_t));
200  pic->mb_mean_buf = av_buffer_allocz(mb_array_size);
201  if (!pic->mb_var_buf || !pic->mc_mb_var_buf || !pic->mb_mean_buf)
202  return AVERROR(ENOMEM);
203  }
204 
205  if (out_format == FMT_H263 || encoding ||
206 #if FF_API_DEBUG_MV
207  avctx->debug_mv ||
208 #endif
209  (avctx->flags2 & AV_CODEC_FLAG2_EXPORT_MVS)) {
210  int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
211  int ref_index_size = 4 * mb_array_size;
212 
213  for (i = 0; mv_size && i < 2; i++) {
214  pic->motion_val_buf[i] = av_buffer_allocz(mv_size);
215  pic->ref_index_buf[i] = av_buffer_allocz(ref_index_size);
216  if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
217  return AVERROR(ENOMEM);
218  }
219  }
220 
221  pic->alloc_mb_width = mb_width;
222  pic->alloc_mb_height = mb_height;
223 
224  return 0;
225 }
226 
227 /**
228  * Allocate a Picture.
229  * The pixels are allocated/set by calling get_buffer() if shared = 0
230  */
232  ScratchpadContext *sc, int shared, int encoding,
233  int chroma_x_shift, int chroma_y_shift, int out_format,
234  int mb_stride, int mb_width, int mb_height, int b8_stride,
235  ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
236 {
237  int i, ret;
238 
239  if (pic->qscale_table_buf)
240  if ( pic->alloc_mb_width != mb_width
241  || pic->alloc_mb_height != mb_height)
243 
244  if (shared) {
245  av_assert0(pic->f->data[0]);
246  pic->shared = 1;
247  } else {
248  av_assert0(!pic->f->buf[0]);
249  if (alloc_frame_buffer(avctx, pic, me, sc,
250  chroma_x_shift, chroma_y_shift,
251  *linesize, *uvlinesize) < 0)
252  return -1;
253 
254  *linesize = pic->f->linesize[0];
255  *uvlinesize = pic->f->linesize[1];
256  }
257 
258  if (!pic->qscale_table_buf)
259  ret = alloc_picture_tables(avctx, pic, encoding, out_format,
260  mb_stride, mb_width, mb_height, b8_stride);
261  else
262  ret = make_tables_writable(pic);
263  if (ret < 0)
264  goto fail;
265 
266  if (encoding) {
267  pic->mb_var = (uint16_t*)pic->mb_var_buf->data;
268  pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data;
269  pic->mb_mean = pic->mb_mean_buf->data;
270  }
271 
272  pic->mbskip_table = pic->mbskip_table_buf->data;
273  pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1;
274  pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1;
275 
276  if (pic->motion_val_buf[0]) {
277  for (i = 0; i < 2; i++) {
278  pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
279  pic->ref_index[i] = pic->ref_index_buf[i]->data;
280  }
281  }
282 
283  return 0;
284 fail:
285  av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
286  ff_mpeg_unref_picture(avctx, pic);
288  return AVERROR(ENOMEM);
289 }
290 
291 /**
292  * Deallocate a picture.
293  */
295 {
296  int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean);
297 
298  pic->tf.f = pic->f;
299  /* WM Image / Screen codecs allocate internal buffers with different
300  * dimensions / colorspaces; ignore user-defined callbacks for these. */
301  if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
302  avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
303  avctx->codec_id != AV_CODEC_ID_MSS2)
304  ff_thread_release_buffer(avctx, &pic->tf);
305  else if (pic->f)
306  av_frame_unref(pic->f);
307 
309 
310  if (pic->needs_realloc)
312 
313  memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
314 }
315 
317 {
318  int i;
319 
320 #define UPDATE_TABLE(table) \
321 do { \
322  if (src->table && \
323  (!dst->table || dst->table->buffer != src->table->buffer)) { \
324  av_buffer_unref(&dst->table); \
325  dst->table = av_buffer_ref(src->table); \
326  if (!dst->table) { \
327  ff_free_picture_tables(dst); \
328  return AVERROR(ENOMEM); \
329  } \
330  } \
331 } while (0)
332 
333  UPDATE_TABLE(mb_var_buf);
334  UPDATE_TABLE(mc_mb_var_buf);
335  UPDATE_TABLE(mb_mean_buf);
336  UPDATE_TABLE(mbskip_table_buf);
337  UPDATE_TABLE(qscale_table_buf);
338  UPDATE_TABLE(mb_type_buf);
339  for (i = 0; i < 2; i++) {
340  UPDATE_TABLE(motion_val_buf[i]);
341  UPDATE_TABLE(ref_index_buf[i]);
342  }
343 
344  dst->mb_var = src->mb_var;
345  dst->mc_mb_var = src->mc_mb_var;
346  dst->mb_mean = src->mb_mean;
347  dst->mbskip_table = src->mbskip_table;
348  dst->qscale_table = src->qscale_table;
349  dst->mb_type = src->mb_type;
350  for (i = 0; i < 2; i++) {
351  dst->motion_val[i] = src->motion_val[i];
352  dst->ref_index[i] = src->ref_index[i];
353  }
354 
355  dst->alloc_mb_width = src->alloc_mb_width;
356  dst->alloc_mb_height = src->alloc_mb_height;
357 
358  return 0;
359 }
360 
362 {
363  int ret;
364 
365  av_assert0(!dst->f->buf[0]);
366  av_assert0(src->f->buf[0]);
367 
368  src->tf.f = src->f;
369  dst->tf.f = dst->f;
370  ret = ff_thread_ref_frame(&dst->tf, &src->tf);
371  if (ret < 0)
372  goto fail;
373 
374  ret = ff_update_picture_tables(dst, src);
375  if (ret < 0)
376  goto fail;
377 
378  if (src->hwaccel_picture_private) {
380  if (!dst->hwaccel_priv_buf)
381  goto fail;
383  }
384 
385  dst->field_picture = src->field_picture;
386  dst->mb_var_sum = src->mb_var_sum;
387  dst->mc_mb_var_sum = src->mc_mb_var_sum;
388  dst->b_frame_score = src->b_frame_score;
389  dst->needs_realloc = src->needs_realloc;
390  dst->reference = src->reference;
391  dst->shared = src->shared;
392 
393  memcpy(dst->encoding_error, src->encoding_error,
394  sizeof(dst->encoding_error));
395 
396  return 0;
397 fail:
398  ff_mpeg_unref_picture(avctx, dst);
399  return ret;
400 }
401 
402 static inline int pic_is_unused(Picture *pic)
403 {
404  if (!pic->f->buf[0])
405  return 1;
406  if (pic->needs_realloc && !(pic->reference & DELAYED_PIC_REF))
407  return 1;
408  return 0;
409 }
410 
411 static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
412 {
413  int i;
414 
415  if (shared) {
416  for (i = 0; i < MAX_PICTURE_COUNT; i++) {
417  if (!picture[i].f->buf[0])
418  return i;
419  }
420  } else {
421  for (i = 0; i < MAX_PICTURE_COUNT; i++) {
422  if (pic_is_unused(&picture[i]))
423  return i;
424  }
425  }
426 
427  av_log(avctx, AV_LOG_FATAL,
428  "Internal error, picture buffer overflow\n");
429  /* We could return -1, but the codec would crash trying to draw into a
430  * non-existing frame anyway. This is safer than waiting for a random crash.
431  * Also the return of this is never useful, an encoder must only allocate
432  * as much as allowed in the specification. This has no relationship to how
433  * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
434  * enough for such valid streams).
435  * Plus, a decoder has to check stream validity and remove frames if too
436  * many reference frames are around. Waiting for "OOM" is not correct at
437  * all. Similarly, missing reference frames have to be replaced by
438  * interpolated/MC frames, anything else is a bug in the codec ...
439  */
440  abort();
441  return -1;
442 }
443 
444 int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
445 {
446  int ret = find_unused_picture(avctx, picture, shared);
447 
448  if (ret >= 0 && ret < MAX_PICTURE_COUNT) {
449  if (picture[ret].needs_realloc) {
450  picture[ret].needs_realloc = 0;
451  ff_free_picture_tables(&picture[ret]);
452  ff_mpeg_unref_picture(avctx, &picture[ret]);
453  }
454  }
455  return ret;
456 }
457 
459 {
460  int i;
461 
462  pic->alloc_mb_width =
463  pic->alloc_mb_height = 0;
464 
471 
472  for (i = 0; i < 2; i++) {
474  av_buffer_unref(&pic->ref_index_buf[i]);
475  }
476 }
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free.
Definition: motion_est.h:52
const struct AVCodec * codec
Definition: avcodec.h:1770
int8_t * ref_index[2]
Definition: mpegpicture.h:62
AVBufferRef * mb_var_buf
Definition: mpegpicture.h:64
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:125
#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
Definition: internal.h:160
uint8_t * mb_mean
Table for MB luminance.
Definition: mpegpicture.h:74
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
Definition: mpegpicture.h:36
AVFrame * f
Definition: thread.h:36
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:393
uint16_t * mb_var
Table for MB variances.
Definition: mpegpicture.h:65
static int pic_is_unused(Picture *pic)
Definition: mpegpicture.c:402
#define me
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
Definition: mpegpicture.h:85
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
Definition: diracdec.c:66
int field_picture
whether or not the picture was encoded in separate fields
Definition: mpegpicture.h:79
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1989
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.
Definition: mpegpicture.c:98
int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src)
Definition: mpegpicture.c:361
#define src
Definition: vp8dsp.c:254
int b_frame_score
Definition: mpegpicture.h:84
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:169
int alloc_mb_width
mb_width used to allocate tables
Definition: mpegpicture.h:70
struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:3082
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
uint8_t
static int make_tables_writable(Picture *pic)
Definition: mpegpicture.c:31
Motion estimation context.
Definition: motion_est.h:47
#define FF_API_DEBUG_MV
Definition: version.h:82
void ff_free_picture_tables(Picture *pic)
Definition: mpegpicture.c:458
int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
Definition: mpegpicture.c:444
#define FF_API_CAP_VDPAU
Definition: version.h:70
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
Definition: utils.c:2060
#define AV_CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
Definition: avcodec.h:1038
AVBufferRef * mb_type_buf
Definition: mpegpicture.h:55
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
#define UPDATE_TABLE(table)
AVBufferRef * mb_mean_buf
Definition: mpegpicture.h:73
#define EDGE_WIDTH
Definition: mpegpicture.h:33
ThreadFrame tf
Definition: mpegpicture.h:47
int width
Definition: frame.h:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
uint8_t * mbskip_table
Definition: mpegpicture.h:59
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)
Definition: mpegpicture.c:181
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
Definition: mpegpicture.h:37
#define AVERROR(e)
Definition: error.h:43
uint64_t encoding_error[AV_NUM_DATA_POINTERS]
Definition: mpegpicture.h:90
#define MAX_PICTURE_COUNT
Definition: mpegpicture.h:32
int reference
Definition: mpegpicture.h:87
const char * r
Definition: vf_curves.c:111
int capabilities
Codec capabilities.
Definition: avcodec.h:3758
simple assert() macros that are a bit more flexible than ISO C assert().
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define fail()
Definition: checkasm.h:109
AVBufferRef * hwaccel_priv_buf
Definition: mpegpicture.h:76
AVBufferRef * motion_val_buf[2]
Definition: mpegpicture.h:52
int width
picture width / height.
Definition: avcodec.h:1948
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:53
Picture.
Definition: mpegpicture.h:45
void * hwaccel_picture_private
Hardware accelerator private data.
Definition: mpegpicture.h:77
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:274
uint16_t * mc_mb_var
Table for motion compensated MB variances.
Definition: mpegpicture.h:68
AVBufferRef * qscale_table_buf
Definition: mpegpicture.h:49
int alloc_mb_height
mb_height used to allocate tables
Definition: mpegpicture.h:71
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
Definition: decode.c:1447
Libavcodec external API header.
enum AVCodecID codec_id
Definition: avcodec.h:1778
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
Definition: avcodec.h:1761
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.
Definition: mpegpicture.c:231
uint8_t * data
The data buffer.
Definition: buffer.h:89
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:83
int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, ScratchpadContext *sc, int linesize)
Definition: mpegpicture.c:56
int64_t mc_mb_var_sum
motion compensated MB variance for current frame
Definition: mpegpicture.h:82
struct AVFrame * f
Definition: mpegpicture.h:46
static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
Definition: mpegpicture.c:411
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:505
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
int8_t * qscale_table
Definition: mpegpicture.h:50
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
Deallocate a picture.
Definition: mpegpicture.c:294
#define MAKE_WRITABLE(table)
common internal and external API header
if(ret< 0)
Definition: vf_mcdeint.c:279
AVBufferRef * mbskip_table_buf
Definition: mpegpicture.h:58
int shared
Definition: mpegpicture.h:88
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
uint8_t * b_scratchpad
scratchpad used for writing into write only buffers
Definition: mpegpicture.h:39
int ff_update_picture_tables(Picture *dst, Picture *src)
Definition: mpegpicture.c:316
uint8_t * obmc_scratchpad
Definition: mpegpicture.h:38
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
Definition: avcodec.h:3964
AVBufferRef * mc_mb_var_buf
Definition: mpegpicture.h:67
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:1863
#define AV_CODEC_FLAG2_EXPORT_MVS
Export motion vectors through frame side data.
Definition: avcodec.h:976
int height
Definition: frame.h:259
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:56
#define av_freep(p)
uint8_t * temp
Definition: motion_est.h:56
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:170
int debug_mv
debug
Definition: avcodec.h:3039
int64_t mb_var_sum
sum of MB variance for current frame
Definition: mpegpicture.h:81
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:1397
AVBufferRef * ref_index_buf[2]
Definition: mpegpicture.h:61