FFmpeg
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 #include "libavutil/pixdesc.h"
26 #include "libavutil/imgutils.h"
27 
28 #include "avcodec.h"
29 #include "encode.h"
30 #include "internal.h"
31 #include "decode.h"
32 #include "motion_est.h"
33 #include "mpegpicture.h"
34 #include "mpegutils.h"
35 #include "threadframe.h"
36 
38 {
39  pic->alloc_mb_width =
40  pic->alloc_mb_height = 0;
41 
45 
46  for (int i = 0; i < 2; i++) {
49  }
50 }
51 
53 {
54  AVBufferRef *old = *ref, *new;
55 
56  if (av_buffer_is_writable(old))
57  return 0;
58  new = av_buffer_allocz(old->size);
59  if (!new)
60  return AVERROR(ENOMEM);
62  *ref = new;
63  return 0;
64 }
65 
66 static int make_tables_writable(Picture *pic)
67 {
68 #define MAKE_WRITABLE(table) \
69 do {\
70  int ret = make_table_writable(&pic->table); \
71  if (ret < 0) \
72  return ret; \
73 } while (0)
74 
75  MAKE_WRITABLE(mbskip_table_buf);
76  MAKE_WRITABLE(qscale_table_buf);
77  MAKE_WRITABLE(mb_type_buf);
78 
79  if (pic->motion_val_buf[0]) {
80  for (int i = 0; i < 2; i++) {
81  MAKE_WRITABLE(motion_val_buf[i]);
82  MAKE_WRITABLE(ref_index_buf[i]);
83  }
84  }
85 
86  return 0;
87 }
88 
90  ScratchpadContext *sc, int linesize)
91 {
92 # define EMU_EDGE_HEIGHT (4 * 70)
93  int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
94 
95  if (avctx->hwaccel)
96  return 0;
97 
98  if (linesize < 24) {
99  av_log(avctx, AV_LOG_ERROR, "Image too small, temporary buffers cannot function\n");
100  return AVERROR_PATCHWELCOME;
101  }
102 
103  if (av_image_check_size2(alloc_size, EMU_EDGE_HEIGHT, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0)
104  return AVERROR(ENOMEM);
105 
106  // edge emu needs blocksize + filter length - 1
107  // (= 17x17 for halfpel / 21x21 for H.264)
108  // VC-1 computes luma and chroma simultaneously and needs 19X19 + 9x9
109  // at uvlinesize. It supports only YUV420 so 24x24 is enough
110  // linesize * interlaced * MBsize
111  // we also use this buffer for encoding in encode_mb_internal() needig an additional 32 lines
112  if (!FF_ALLOCZ_TYPED_ARRAY(sc->edge_emu_buffer, alloc_size * EMU_EDGE_HEIGHT) ||
113  !FF_ALLOCZ_TYPED_ARRAY(me->scratchpad, alloc_size * 4 * 16 * 2)) {
115  return AVERROR(ENOMEM);
116  }
117 
118  me->temp = me->scratchpad;
119  sc->rd_scratchpad = me->scratchpad;
120  sc->b_scratchpad = me->scratchpad;
121  sc->obmc_scratchpad = me->scratchpad + 16;
122 
123  return 0;
124 }
125 
126 /**
127  * Allocate a frame buffer
128  */
129 static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic,
131  int chroma_x_shift, int chroma_y_shift,
132  int linesize, int uvlinesize)
133 {
134  int edges_needed = av_codec_is_encoder(avctx->codec);
135  int r, ret;
136 
137  pic->tf.f = pic->f;
138 
139  if (edges_needed) {
140  pic->f->width = avctx->width + 2 * EDGE_WIDTH;
141  pic->f->height = avctx->height + 2 * EDGE_WIDTH;
142 
143  r = ff_encode_alloc_frame(avctx, pic->f);
144  } else if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
145  avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
146  avctx->codec_id != AV_CODEC_ID_MSS2) {
147  r = ff_thread_get_ext_buffer(avctx, &pic->tf,
148  pic->reference ? AV_GET_BUFFER_FLAG_REF : 0);
149  } else {
150  pic->f->width = avctx->width;
151  pic->f->height = avctx->height;
152  pic->f->format = avctx->pix_fmt;
153  r = avcodec_default_get_buffer2(avctx, pic->f, 0);
154  }
155 
156  if (r < 0 || !pic->f->buf[0]) {
157  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n",
158  r, pic->f->data[0]);
159  return -1;
160  }
161 
162  if (edges_needed) {
163  int i;
164  for (i = 0; pic->f->data[i]; i++) {
165  int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) *
166  pic->f->linesize[i] +
167  (EDGE_WIDTH >> (i ? chroma_x_shift : 0));
168  pic->f->data[i] += offset;
169  }
170  pic->f->width = avctx->width;
171  pic->f->height = avctx->height;
172  }
173 
174  if (avctx->hwaccel) {
175  assert(!pic->hwaccel_picture_private);
176  if (avctx->hwaccel->frame_priv_data_size) {
178  if (!pic->hwaccel_priv_buf) {
179  av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
180  return -1;
181  }
183  }
184  }
185 
186  if ((linesize && linesize != pic->f->linesize[0]) ||
187  (uvlinesize && uvlinesize != pic->f->linesize[1])) {
188  av_log(avctx, AV_LOG_ERROR,
189  "get_buffer() failed (stride changed: linesize=%d/%d uvlinesize=%d/%d)\n",
190  linesize, pic->f->linesize[0],
191  uvlinesize, pic->f->linesize[1]);
192  ff_mpeg_unref_picture(avctx, pic);
193  return -1;
194  }
195 
196  if (av_pix_fmt_count_planes(pic->f->format) > 2 &&
197  pic->f->linesize[1] != pic->f->linesize[2]) {
198  av_log(avctx, AV_LOG_ERROR,
199  "get_buffer() failed (uv stride mismatch)\n");
200  ff_mpeg_unref_picture(avctx, pic);
201  return -1;
202  }
203 
204  if (!sc->edge_emu_buffer &&
205  (ret = ff_mpeg_framesize_alloc(avctx, me, sc,
206  pic->f->linesize[0])) < 0) {
207  av_log(avctx, AV_LOG_ERROR,
208  "get_buffer() failed to allocate context scratch buffers.\n");
209  ff_mpeg_unref_picture(avctx, pic);
210  return ret;
211  }
212 
213  return 0;
214 }
215 
216 static int alloc_picture_tables(AVCodecContext *avctx, Picture *pic, int encoding, int out_format,
217  int mb_stride, int mb_width, int mb_height, int b8_stride)
218 {
219  const int big_mb_num = mb_stride * (mb_height + 1) + 1;
220  const int mb_array_size = mb_stride * mb_height;
221  const int b8_array_size = b8_stride * mb_height * 2;
222  int i;
223 
224 
225  pic->mbskip_table_buf = av_buffer_allocz(mb_array_size + 2);
226  pic->qscale_table_buf = av_buffer_allocz(big_mb_num + mb_stride);
227  pic->mb_type_buf = av_buffer_allocz((big_mb_num + mb_stride) *
228  sizeof(uint32_t));
229  if (!pic->mbskip_table_buf || !pic->qscale_table_buf || !pic->mb_type_buf)
230  return AVERROR(ENOMEM);
231 
232  if (out_format == FMT_H263 || encoding ||
234  int mv_size = 2 * (b8_array_size + 4) * sizeof(int16_t);
235  int ref_index_size = 4 * mb_array_size;
236 
237  for (i = 0; mv_size && i < 2; i++) {
238  pic->motion_val_buf[i] = av_buffer_allocz(mv_size);
239  pic->ref_index_buf[i] = av_buffer_allocz(ref_index_size);
240  if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i])
241  return AVERROR(ENOMEM);
242  }
243  }
244 
245  pic->alloc_mb_width = mb_width;
246  pic->alloc_mb_height = mb_height;
247  pic->alloc_mb_stride = mb_stride;
248 
249  return 0;
250 }
251 
252 /**
253  * Allocate a Picture.
254  * The pixels are allocated/set by calling get_buffer() if shared = 0
255  */
257  ScratchpadContext *sc, int shared, int encoding,
258  int chroma_x_shift, int chroma_y_shift, int out_format,
259  int mb_stride, int mb_width, int mb_height, int b8_stride,
260  ptrdiff_t *linesize, ptrdiff_t *uvlinesize)
261 {
262  int i, ret;
263 
264  if (pic->qscale_table_buf)
265  if ( pic->alloc_mb_width != mb_width
266  || pic->alloc_mb_height != mb_height)
267  free_picture_tables(pic);
268 
269  if (shared) {
270  av_assert0(pic->f->data[0]);
271  pic->shared = 1;
272  } else {
273  av_assert0(!pic->f->buf[0]);
274  if (alloc_frame_buffer(avctx, pic, me, sc,
275  chroma_x_shift, chroma_y_shift,
276  *linesize, *uvlinesize) < 0)
277  return -1;
278 
279  *linesize = pic->f->linesize[0];
280  *uvlinesize = pic->f->linesize[1];
281  }
282 
283  if (!pic->qscale_table_buf)
284  ret = alloc_picture_tables(avctx, pic, encoding, out_format,
285  mb_stride, mb_width, mb_height, b8_stride);
286  else
287  ret = make_tables_writable(pic);
288  if (ret < 0)
289  goto fail;
290 
291  pic->mbskip_table = pic->mbskip_table_buf->data;
292  pic->qscale_table = pic->qscale_table_buf->data + 2 * mb_stride + 1;
293  pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * mb_stride + 1;
294 
295  if (pic->motion_val_buf[0]) {
296  for (i = 0; i < 2; i++) {
297  pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
298  pic->ref_index[i] = pic->ref_index_buf[i]->data;
299  }
300  }
301 
302  return 0;
303 fail:
304  av_log(avctx, AV_LOG_ERROR, "Error allocating a picture.\n");
305  ff_mpeg_unref_picture(avctx, pic);
306  free_picture_tables(pic);
307  return AVERROR(ENOMEM);
308 }
309 
310 /**
311  * Deallocate a picture; frees the picture tables in case they
312  * need to be reallocated anyway.
313  */
315 {
316  pic->tf.f = pic->f;
317  /* WM Image / Screen codecs allocate internal buffers with different
318  * dimensions / colorspaces; ignore user-defined callbacks for these. */
319  if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE &&
320  avctx->codec_id != AV_CODEC_ID_VC1IMAGE &&
321  avctx->codec_id != AV_CODEC_ID_MSS2)
322  ff_thread_release_ext_buffer(avctx, &pic->tf);
323  else if (pic->f)
324  av_frame_unref(pic->f);
325 
327 
328  if (pic->needs_realloc)
329  free_picture_tables(pic);
330 
332  pic->field_picture = 0;
333  pic->b_frame_score = 0;
334  pic->needs_realloc = 0;
335  pic->reference = 0;
336  pic->shared = 0;
337  pic->display_picture_number = 0;
338  pic->coded_picture_number = 0;
339 }
340 
342 {
343  int i, ret;
344 
345  ret = av_buffer_replace(&dst->mbskip_table_buf, src->mbskip_table_buf);
346  ret |= av_buffer_replace(&dst->qscale_table_buf, src->qscale_table_buf);
347  ret |= av_buffer_replace(&dst->mb_type_buf, src->mb_type_buf);
348  for (i = 0; i < 2; i++) {
349  ret |= av_buffer_replace(&dst->motion_val_buf[i], src->motion_val_buf[i]);
350  ret |= av_buffer_replace(&dst->ref_index_buf[i], src->ref_index_buf[i]);
351  }
352 
353  if (ret < 0) {
354  free_picture_tables(dst);
355  return ret;
356  }
357 
358  dst->mbskip_table = src->mbskip_table;
359  dst->qscale_table = src->qscale_table;
360  dst->mb_type = src->mb_type;
361  for (i = 0; i < 2; i++) {
362  dst->motion_val[i] = src->motion_val[i];
363  dst->ref_index[i] = src->ref_index[i];
364  }
365 
366  dst->alloc_mb_width = src->alloc_mb_width;
367  dst->alloc_mb_height = src->alloc_mb_height;
368  dst->alloc_mb_stride = src->alloc_mb_stride;
369 
370  return 0;
371 }
372 
374 {
375  int ret;
376 
377  av_assert0(!dst->f->buf[0]);
378  av_assert0(src->f->buf[0]);
379 
380  src->tf.f = src->f;
381  dst->tf.f = dst->f;
382  ret = ff_thread_ref_frame(&dst->tf, &src->tf);
383  if (ret < 0)
384  goto fail;
385 
387  if (ret < 0)
388  goto fail;
389 
390  if (src->hwaccel_picture_private) {
391  dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
392  if (!dst->hwaccel_priv_buf) {
393  ret = AVERROR(ENOMEM);
394  goto fail;
395  }
397  }
398 
399  dst->field_picture = src->field_picture;
400  dst->b_frame_score = src->b_frame_score;
401  dst->needs_realloc = src->needs_realloc;
402  dst->reference = src->reference;
403  dst->shared = src->shared;
404  dst->display_picture_number = src->display_picture_number;
405  dst->coded_picture_number = src->coded_picture_number;
406 
407  return 0;
408 fail:
409  ff_mpeg_unref_picture(avctx, dst);
410  return ret;
411 }
412 
413 static inline int pic_is_unused(Picture *pic)
414 {
415  if (!pic->f->buf[0])
416  return 1;
417  if (pic->needs_realloc)
418  return 1;
419  return 0;
420 }
421 
422 static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
423 {
424  int i;
425 
426  if (shared) {
427  for (i = 0; i < MAX_PICTURE_COUNT; i++) {
428  if (!picture[i].f->buf[0])
429  return i;
430  }
431  } else {
432  for (i = 0; i < MAX_PICTURE_COUNT; i++) {
433  if (pic_is_unused(&picture[i]))
434  return i;
435  }
436  }
437 
438  av_log(avctx, AV_LOG_FATAL,
439  "Internal error, picture buffer overflow\n");
440  /* We could return -1, but the codec would crash trying to draw into a
441  * non-existing frame anyway. This is safer than waiting for a random crash.
442  * Also the return of this is never useful, an encoder must only allocate
443  * as much as allowed in the specification. This has no relationship to how
444  * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
445  * enough for such valid streams).
446  * Plus, a decoder has to check stream validity and remove frames if too
447  * many reference frames are around. Waiting for "OOM" is not correct at
448  * all. Similarly, missing reference frames have to be replaced by
449  * interpolated/MC frames, anything else is a bug in the codec ...
450  */
451  abort();
452  return -1;
453 }
454 
455 int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
456 {
457  int ret = find_unused_picture(avctx, picture, shared);
458 
459  if (ret >= 0 && ret < MAX_PICTURE_COUNT) {
460  if (picture[ret].needs_realloc) {
461  ff_mpeg_unref_picture(avctx, &picture[ret]);
462  }
463  }
464  return ret;
465 }
466 
468 {
469  free_picture_tables(pic);
470  ff_mpeg_unref_picture(avctx, pic);
471  av_frame_free(&pic->f);
472 }
FF_ALLOCZ_TYPED_ARRAY
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
Definition: internal.h:96
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1429
Picture::ref_index_buf
AVBufferRef * ref_index_buf[2]
Definition: mpegpicture.h:62
EMU_EDGE_HEIGHT
#define EMU_EDGE_HEIGHT
ScratchpadContext::obmc_scratchpad
uint8_t * obmc_scratchpad
Definition: mpegpicture.h:39
ff_mpeg_framesize_alloc
int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, ScratchpadContext *sc, int linesize)
Definition: mpegpicture.c:89
r
const char * r
Definition: vf_curves.c:126
AVERROR
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
free_picture_tables
static void av_noinline free_picture_tables(Picture *pic)
Definition: mpegpicture.c:37
ff_thread_release_ext_buffer
void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f)
Unref a ThreadFrame.
Definition: pthread_frame.c:1045
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
ScratchpadContext::rd_scratchpad
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
Definition: mpegpicture.h:38
MotionEstContext
Motion estimation context.
Definition: motion_est.h:47
Picture::alloc_mb_width
int alloc_mb_width
mb_width used to allocate tables
Definition: mpegpicture.h:65
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
Picture::field_picture
int field_picture
whether or not the picture was encoded in separate fields
Definition: mpegpicture.h:72
pixdesc.h
AVFrame::width
int width
Definition: frame.h:402
internal.h
encode.h
Picture::ref_index
int8_t * ref_index[2]
Definition: mpegpicture.h:63
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
Picture
Picture.
Definition: mpegpicture.h:46
mpegutils.h
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:580
make_tables_writable
static int make_tables_writable(Picture *pic)
Definition: mpegpicture.c:66
ThreadFrame::f
AVFrame * f
Definition: threadframe.h:28
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:351
ScratchpadContext
Definition: mpegpicture.h:36
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2976
Picture::needs_realloc
int needs_realloc
Picture needs to be reallocated (eg due to a frame size change)
Definition: mpegpicture.h:75
alloc_picture_tables
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:216
AVCodecContext::codec
const struct AVCodec * codec
Definition: avcodec.h:444
fail
#define fail()
Definition: checkasm.h:137
Picture::mbskip_table
uint8_t * mbskip_table
Definition: mpegpicture.h:60
av_noinline
#define av_noinline
Definition: attributes.h:72
motion_est.h
ff_hwaccel_frame_priv_alloc
AVBufferRef * ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, const AVHWAccel *hwaccel)
Allocate a hwaccel frame private data and create an AVBufferRef from it.
Definition: decode.c:1722
MAX_PICTURE_COUNT
#define MAX_PICTURE_COUNT
Definition: mpegpicture.h:33
av_image_check_size2
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...
Definition: imgutils.c:289
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
Picture::b_frame_score
int b_frame_score
Definition: mpegpicture.h:74
ff_mpeg_unref_picture
void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
Deallocate a picture; frees the picture tables in case they need to be reallocated anyway.
Definition: mpegpicture.c:314
Picture::hwaccel_priv_buf
AVBufferRef * hwaccel_priv_buf
Definition: mpegpicture.h:69
AV_GET_BUFFER_FLAG_REF
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:413
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
decode.h
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1941
AV_CODEC_ID_VC1IMAGE
@ AV_CODEC_ID_VC1IMAGE
Definition: codec_id.h:204
Picture::hwaccel_picture_private
void * hwaccel_picture_private
Hardware accelerator private data.
Definition: mpegpicture.h:70
AVCodecContext::codec_id
enum AVCodecID codec_id
Definition: avcodec.h:445
ff_thread_ref_frame
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
Definition: utils.c:896
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:64
if
if(ret)
Definition: filter_design.txt:179
Picture::reference
int reference
Definition: mpegpicture.h:77
Picture::mb_type_buf
AVBufferRef * mb_type_buf
Definition: mpegpicture.h:56
ff_find_unused_picture
int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
Definition: mpegpicture.c:455
threadframe.h
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_buffer_unref
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:139
me
#define me
Definition: vf_colormatrix.c:104
EDGE_WIDTH
#define EDGE_WIDTH
Definition: mpegpicture.h:34
ff_update_picture_tables
int ff_update_picture_tables(Picture *dst, const Picture *src)
Definition: mpegpicture.c:341
Picture::motion_val_buf
AVBufferRef * motion_val_buf[2]
Definition: mpegpicture.h:53
Picture::tf
ThreadFrame tf
Definition: mpegpicture.h:48
ff_alloc_picture
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:256
alloc_frame_buffer
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:129
ff_encode_alloc_frame
int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
Allocate buffers for a frame.
Definition: encode.c:741
f
f
Definition: af_crystalizer.c:122
Picture::display_picture_number
int display_picture_number
Definition: mpegpicture.h:80
ff_mpeg_ref_picture
int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src)
Definition: mpegpicture.c:373
Picture::qscale_table_buf
AVBufferRef * qscale_table_buf
Definition: mpegpicture.h:50
Picture::alloc_mb_height
int alloc_mb_height
mb_height used to allocate tables
Definition: mpegpicture.h:66
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:417
mpegpicture.h
offset
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
Definition: writing_filters.txt:86
Picture::motion_val
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:54
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
AV_CODEC_ID_MSS2
@ AV_CODEC_ID_MSS2
Definition: codec_id.h:219
av_codec_is_encoder
int av_codec_is_encoder(const AVCodec *codec)
Definition: utils.c:75
avcodec_default_get_buffer2
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
Definition: get_buffer.c:282
FMT_H263
@ FMT_H263
Definition: mpegutils.h:119
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
MAKE_WRITABLE
#define MAKE_WRITABLE(table)
common.h
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:622
ff_mpv_picture_free
void av_cold ff_mpv_picture_free(AVCodecContext *avctx, Picture *pic)
Definition: mpegpicture.c:467
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
AVCodecContext::height
int height
Definition: avcodec.h:615
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:652
ff_thread_get_ext_buffer
int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around ff_get_buffer() for frame-multithreaded codecs.
Definition: pthread_frame.c:1003
av_buffer_is_writable
int av_buffer_is_writable(const AVBufferRef *buf)
Definition: buffer.c:147
avcodec.h
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
ret
ret
Definition: filter_design.txt:187
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
Picture::qscale_table
int8_t * qscale_table
Definition: mpegpicture.h:51
pic_is_unused
static int pic_is_unused(Picture *pic)
Definition: mpegpicture.c:413
Picture::coded_picture_number
int coded_picture_number
Definition: mpegpicture.h:81
AVCodecContext
main external API structure.
Definition: avcodec.h:435
AVFrame::height
int height
Definition: frame.h:402
Picture::shared
int shared
Definition: mpegpicture.h:78
ScratchpadContext::edge_emu_buffer
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
Definition: mpegpicture.h:37
Picture::mb_type
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:57
Picture::f
struct AVFrame * f
Definition: mpegpicture.h:47
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVHWAccel::frame_priv_data_size
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
Definition: avcodec.h:2220
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVCodecContext::export_side_data
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Definition: avcodec.h:2039
find_unused_picture
static int find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared)
Definition: mpegpicture.c:422
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AV_CODEC_EXPORT_DATA_MVS
#define AV_CODEC_EXPORT_DATA_MVS
Export motion vectors through frame side data.
Definition: avcodec.h:394
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:615
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:375
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
Picture::mbskip_table_buf
AVBufferRef * mbskip_table_buf
Definition: mpegpicture.h:59
AV_CODEC_ID_WMV3IMAGE
@ AV_CODEC_ID_WMV3IMAGE
Definition: codec_id.h:203
ScratchpadContext::b_scratchpad
uint8_t * b_scratchpad
scratchpad used for writing into write only buffers
Definition: mpegpicture.h:40
Picture::alloc_mb_stride
int alloc_mb_stride
mb_stride used to allocate tables
Definition: mpegpicture.h:67
make_table_writable
static int make_table_writable(AVBufferRef **ref)
Definition: mpegpicture.c:52