FFmpeg
mpegpicture.h
Go to the documentation of this file.
1 /*
2  * Mpeg video formats-related defines and utility 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 #ifndef AVCODEC_MPEGPICTURE_H
22 #define AVCODEC_MPEGPICTURE_H
23 
24 #include <limits.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #include "avcodec.h"
29 #include "threadprogress.h"
30 
31 #define MPV_MAX_PLANES 3
32 #define EDGE_WIDTH 16
33 
34 typedef struct ScratchpadContext {
35  uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data
36  uint8_t *obmc_scratchpad;
37  union {
38  uint8_t *scratchpad_buf; ///< the other *_scratchpad point into this buffer
39  uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
40  };
41  int linesize; ///< linesize that the buffers in this context have been allocated for
43 
44 typedef struct BufferPoolContext {
50  int alloc_mb_width; ///< mb_width used to allocate tables
51  int alloc_mb_height; ///< mb_height used to allocate tables
52  int alloc_mb_stride; ///< mb_stride used to allocate tables
54 
55 /**
56  * MPVPicture.
57  */
58 typedef struct MPVPicture {
59  struct AVFrame *f;
60 
62  int8_t *qscale_table;
63 
64  int16_t (*motion_val_base[2])[2];
65  int16_t (*motion_val[2])[2];
66 
67  uint32_t *mb_type_base;
68  uint32_t *mb_type; ///< types and macros are defined in mpegutils.h
69 
70  uint8_t *mbskip_table;
71 
72  int8_t *ref_index[2];
73 
74  /// RefStruct reference for hardware accelerator private data
76 
77  int mb_width; ///< mb_width of the tables
78  int mb_height; ///< mb_height of the tables
79  int mb_stride; ///< mb_stride of the tables
80 
81  int dummy; ///< Picture is a dummy and should not be output
82  int field_picture; ///< whether or not the picture was encoded in separate fields
83 
85 
86  int reference;
87  int shared;
88 
91 
93 } MPVPicture;
94 
95 typedef struct MPVWorkPicture {
96  uint8_t *data[MPV_MAX_PLANES];
98 
99  MPVPicture *ptr; ///< RefStruct reference
100 
101  int8_t *qscale_table;
102 
103  int16_t (*motion_val[2])[2];
104 
105  uint32_t *mb_type; ///< types and macros are defined in mpegutils.h
106 
107  uint8_t *mbskip_table;
108 
109  int8_t *ref_index[2];
110 
113 
114 /**
115  * Allocate a pool of MPVPictures.
116  */
117 struct FFRefStructPool *ff_mpv_alloc_pic_pool(int init_progress);
118 
119 /**
120  * Allocate an MPVPicture's accessories (but not the AVFrame's buffer itself)
121  * and set the MPVWorkPicture's fields.
122  */
124  ScratchpadContext *sc,
125  BufferPoolContext *pools, int mb_height);
126 
127 /**
128  * Check that the linesizes of an AVFrame are consistent with the requirements
129  * of mpegvideo.
130  * FIXME: There should be no need for this function. mpegvideo should be made
131  * to work with changing linesizes.
132  */
133 int ff_mpv_pic_check_linesize(void *logctx, const struct AVFrame *f,
134  ptrdiff_t *linesizep, ptrdiff_t *uvlinesizep);
135 
137  ScratchpadContext *sc, int linesize);
138 
139 /**
140  * Disable allocating the ScratchpadContext's buffers in future calls
141  * to ff_mpv_framesize_alloc().
142  */
144 {
145  sc->linesize = INT_MAX;
146 }
147 
151 
152 #endif /* AVCODEC_MPEGPICTURE_H */
MPV_MAX_PLANES
#define MPV_MAX_PLANES
Definition: mpegpicture.h:31
MPVWorkPicture::linesize
ptrdiff_t linesize[MPV_MAX_PLANES]
Definition: mpegpicture.h:97
ScratchpadContext::obmc_scratchpad
uint8_t * obmc_scratchpad
Definition: mpegpicture.h:36
threadprogress.h
ThreadProgress
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
Definition: threadprogress.h:43
ScratchpadContext::rd_scratchpad
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
Definition: mpegpicture.h:39
MPVPicture::mbskip_table
uint8_t * mbskip_table
Definition: mpegpicture.h:70
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
ff_mpv_framesize_disable
static void ff_mpv_framesize_disable(ScratchpadContext *sc)
Disable allocating the ScratchpadContext's buffers in future calls to ff_mpv_framesize_alloc().
Definition: mpegpicture.h:143
ff_mpv_alloc_pic_accessories
int ff_mpv_alloc_pic_accessories(AVCodecContext *avctx, MPVWorkPicture *pic, ScratchpadContext *sc, BufferPoolContext *pools, int mb_height)
Allocate an MPVPicture's accessories (but not the AVFrame's buffer itself) and set the MPVWorkPicture...
Definition: mpegpicture.c:237
MPVPicture::mb_type_base
uint32_t * mb_type_base
Definition: mpegpicture.h:67
MPVWorkPicture::mb_type
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:105
ScratchpadContext
Definition: mpegpicture.h:34
MPVWorkPicture::motion_val
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:103
MPVPicture::motion_val_base
int16_t(*[2] motion_val_base)[2]
Definition: mpegpicture.h:64
MPVPicture::mb_type
uint32_t * mb_type
types and macros are defined in mpegutils.h
Definition: mpegpicture.h:68
MPVPicture::motion_val
int16_t(*[2] motion_val)[2]
Definition: mpegpicture.h:65
BufferPoolContext::mb_type_pool
struct FFRefStructPool * mb_type_pool
Definition: mpegpicture.h:47
BufferPoolContext::alloc_mb_stride
int alloc_mb_stride
mb_stride used to allocate tables
Definition: mpegpicture.h:52
MPVWorkPicture::mbskip_table
uint8_t * mbskip_table
Definition: mpegpicture.h:107
MPVPicture::dummy
int dummy
Picture is a dummy and should not be output.
Definition: mpegpicture.h:81
MPVPicture::shared
int shared
Definition: mpegpicture.h:87
MPVPicture::coded_picture_number
int coded_picture_number
Definition: mpegpicture.h:90
MPVWorkPicture::ptr
MPVPicture * ptr
RefStruct reference.
Definition: mpegpicture.h:99
limits.h
MPVWorkPicture::reference
int reference
Definition: mpegpicture.h:111
BufferPoolContext::motion_val_pool
struct FFRefStructPool * motion_val_pool
Definition: mpegpicture.h:48
BufferPoolContext::ref_index_pool
struct FFRefStructPool * ref_index_pool
Definition: mpegpicture.h:49
FFRefStructPool
FFRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition: refstruct.c:183
BufferPoolContext::mbskip_table_pool
struct FFRefStructPool * mbskip_table_pool
Definition: mpegpicture.h:45
BufferPoolContext::alloc_mb_height
int alloc_mb_height
mb_height used to allocate tables
Definition: mpegpicture.h:51
MPVPicture::qscale_table_base
int8_t * qscale_table_base
Definition: mpegpicture.h:61
MPVWorkPicture::data
uint8_t * data[MPV_MAX_PLANES]
Definition: mpegpicture.h:96
MPVPicture::field_picture
int field_picture
whether or not the picture was encoded in separate fields
Definition: mpegpicture.h:82
ScratchpadContext::linesize
int linesize
linesize that the buffers in this context have been allocated for
Definition: mpegpicture.h:41
MPVPicture::display_picture_number
int display_picture_number
Definition: mpegpicture.h:89
MPVPicture::reference
int reference
Definition: mpegpicture.h:86
f
f
Definition: af_crystalizer.c:122
MPVPicture::mb_stride
int mb_stride
mb_stride of the tables
Definition: mpegpicture.h:79
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
ff_mpv_framesize_alloc
int ff_mpv_framesize_alloc(AVCodecContext *avctx, ScratchpadContext *sc, int linesize)
Definition: mpegpicture.c:138
ScratchpadContext::scratchpad_buf
uint8_t * scratchpad_buf
the other *_scratchpad point into this buffer
Definition: mpegpicture.h:38
MPVPicture::mb_width
int mb_width
mb_width of the tables
Definition: mpegpicture.h:77
ff_mpv_unref_picture
void ff_mpv_unref_picture(MPVWorkPicture *pic)
Definition: mpegpicture.c:98
MPVWorkPicture::qscale_table
int8_t * qscale_table
Definition: mpegpicture.h:101
MPVPicture::hwaccel_picture_private
void * hwaccel_picture_private
RefStruct reference for hardware accelerator private data.
Definition: mpegpicture.h:75
BufferPoolContext::qscale_table_pool
struct FFRefStructPool * qscale_table_pool
Definition: mpegpicture.h:46
MPVPicture::qscale_table
int8_t * qscale_table
Definition: mpegpicture.h:62
ff_mpv_pic_check_linesize
int ff_mpv_pic_check_linesize(void *logctx, const struct AVFrame *f, ptrdiff_t *linesizep, ptrdiff_t *uvlinesizep)
Check that the linesizes of an AVFrame are consistent with the requirements of mpegvideo.
ff_mpv_replace_picture
void ff_mpv_replace_picture(MPVWorkPicture *dst, const MPVWorkPicture *src)
Definition: mpegpicture.c:121
MPVPicture::mb_height
int mb_height
mb_height of the tables
Definition: mpegpicture.h:78
MPVPicture::b_frame_score
int b_frame_score
Definition: mpegpicture.h:84
avcodec.h
ff_mpv_alloc_pic_pool
struct FFRefStructPool * ff_mpv_alloc_pic_pool(int init_progress)
Allocate a pool of MPVPictures.
Definition: mpegpicture.c:90
MPVPicture::f
struct AVFrame * f
Definition: mpegpicture.h:59
AVCodecContext
main external API structure.
Definition: avcodec.h:451
ScratchpadContext::edge_emu_buffer
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
Definition: mpegpicture.h:35
MPVWorkPicture::ref_index
int8_t * ref_index[2]
Definition: mpegpicture.h:109
MPVWorkPicture
Definition: mpegpicture.h:95
MPVPicture::progress
ThreadProgress progress
Definition: mpegpicture.h:92
BufferPoolContext
Definition: mpegpicture.h:44
MPVPicture
MPVPicture.
Definition: mpegpicture.h:58
BufferPoolContext::alloc_mb_width
int alloc_mb_width
mb_width used to allocate tables
Definition: mpegpicture.h:50
MPVPicture::ref_index
int8_t * ref_index[2]
Definition: mpegpicture.h:72
src
#define src
Definition: vp8dsp.c:248
ff_mpv_workpic_from_pic
void ff_mpv_workpic_from_pic(MPVWorkPicture *wpic, MPVPicture *pic)
Definition: mpegpicture.c:128