You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

987 lines
41KB

  1. /*
  2. * Generic DCT based hybrid video encoder
  3. * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
  4. * Copyright (c) 2002-2004 Michael Niedermayer
  5. *
  6. * This library 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 of the License, or (at your option) any later version.
  10. *
  11. * This library 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 this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. /**
  21. * @file mpegvideo.h
  22. * mpegvideo header.
  23. */
  24. #ifndef AVCODEC_MPEGVIDEO_H
  25. #define AVCODEC_MPEGVIDEO_H
  26. #include "dsputil.h"
  27. #include "bitstream.h"
  28. #define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
  29. enum OutputFormat {
  30. FMT_MPEG1,
  31. FMT_H261,
  32. FMT_H263,
  33. FMT_MJPEG,
  34. FMT_H264,
  35. };
  36. #define EDGE_WIDTH 16
  37. #define MPEG_BUF_SIZE (16 * 1024)
  38. #define QMAT_SHIFT_MMX 16
  39. #define QMAT_SHIFT 22
  40. #define MAX_FCODE 7
  41. #define MAX_MV 2048
  42. #define MAX_THREADS 8
  43. #define MAX_PICTURE_COUNT 32
  44. #define ME_MAP_SIZE 64
  45. #define ME_MAP_SHIFT 3
  46. #define ME_MAP_MV_BITS 11
  47. /* run length table */
  48. #define MAX_RUN 64
  49. #define MAX_LEVEL 64
  50. #define I_TYPE FF_I_TYPE ///< Intra
  51. #define P_TYPE FF_P_TYPE ///< Predicted
  52. #define B_TYPE FF_B_TYPE ///< Bi-dir predicted
  53. #define S_TYPE FF_S_TYPE ///< S(GMC)-VOP MPEG4
  54. #define SI_TYPE FF_SI_TYPE ///< Switching Intra
  55. #define SP_TYPE FF_SP_TYPE ///< Switching Predicted
  56. #define MAX_MB_BYTES (30*16*16*3/8 + 120)
  57. typedef struct Predictor{
  58. double coeff;
  59. double count;
  60. double decay;
  61. } Predictor;
  62. typedef struct RateControlEntry{
  63. int pict_type;
  64. float qscale;
  65. int mv_bits;
  66. int i_tex_bits;
  67. int p_tex_bits;
  68. int misc_bits;
  69. uint64_t expected_bits;
  70. int new_pict_type;
  71. float new_qscale;
  72. int mc_mb_var_sum;
  73. int mb_var_sum;
  74. int i_count;
  75. int f_code;
  76. int b_code;
  77. }RateControlEntry;
  78. /**
  79. * rate control context.
  80. */
  81. typedef struct RateControlContext{
  82. FILE *stats_file;
  83. int num_entries; ///< number of RateControlEntries
  84. RateControlEntry *entry;
  85. double buffer_index; ///< amount of bits in the video/audio buffer
  86. Predictor pred[5];
  87. double short_term_qsum; ///< sum of recent qscales
  88. double short_term_qcount; ///< count of recent qscales
  89. double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
  90. double pass1_wanted_bits; ///< bits which should have been outputed by the pass1 code (including complexity init)
  91. double last_qscale;
  92. double last_qscale_for[5]; ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff
  93. int last_mc_mb_var_sum;
  94. int last_mb_var_sum;
  95. uint64_t i_cplx_sum[5];
  96. uint64_t p_cplx_sum[5];
  97. uint64_t mv_bits_sum[5];
  98. uint64_t qscale_sum[5];
  99. int frame_count[5];
  100. int last_non_b_pict_type;
  101. }RateControlContext;
  102. /**
  103. * Scantable.
  104. */
  105. typedef struct ScanTable{
  106. const uint8_t *scantable;
  107. uint8_t permutated[64];
  108. uint8_t raster_end[64];
  109. #ifdef ARCH_POWERPC
  110. /** Used by dct_quantise_alitvec to find last-non-zero */
  111. uint8_t __align8 inverse[64];
  112. #endif
  113. } ScanTable;
  114. /**
  115. * Picture.
  116. */
  117. typedef struct Picture{
  118. FF_COMMON_FRAME
  119. /**
  120. * halfpel luma planes.
  121. */
  122. uint8_t *interpolated[3];
  123. int16_t (*motion_val_base[2])[2];
  124. uint32_t *mb_type_base;
  125. #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if theres just one type
  126. #define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4)
  127. #define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
  128. #define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
  129. #define IS_INTRA(a) ((a)&7)
  130. #define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
  131. #define IS_SKIP(a) ((a)&MB_TYPE_SKIP)
  132. #define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
  133. #define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
  134. #define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2)
  135. #define IS_GMC(a) ((a)&MB_TYPE_GMC)
  136. #define IS_16X16(a) ((a)&MB_TYPE_16x16)
  137. #define IS_16X8(a) ((a)&MB_TYPE_16x8)
  138. #define IS_8X16(a) ((a)&MB_TYPE_8x16)
  139. #define IS_8X8(a) ((a)&MB_TYPE_8x8)
  140. #define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused
  141. #define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused
  142. #define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused
  143. #define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused
  144. #define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED)
  145. #define IS_QUANT(a) ((a)&MB_TYPE_QUANT)
  146. #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
  147. #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note doesnt work if subMBs
  148. #define HAS_CBP(a) ((a)&MB_TYPE_CBP)
  149. int field_poc[2]; ///< h264 top/bottom POC
  150. int poc; ///< h264 frame POC
  151. int frame_num; ///< h264 frame_num
  152. int pic_id; ///< h264 pic_num or long_term_pic_idx
  153. int long_ref; ///< 1->long term reference 0->short term reference
  154. int ref_poc[2][16]; ///< h264 POCs of the frames used as reference
  155. int ref_count[2]; ///< number of entries in ref_poc
  156. int mb_var_sum; ///< sum of MB variance for current frame
  157. int mc_mb_var_sum; ///< motion compensated MB variance for current frame
  158. uint16_t *mb_var; ///< Table for MB variances
  159. uint16_t *mc_mb_var; ///< Table for motion compensated MB variances
  160. uint8_t *mb_mean; ///< Table for MB luminance
  161. int32_t *mb_cmp_score; ///< Table for MB cmp scores, for mb decision FIXME remove
  162. int b_frame_score; /* */
  163. } Picture;
  164. typedef struct ParseContext{
  165. uint8_t *buffer;
  166. int index;
  167. int last_index;
  168. int buffer_size;
  169. uint32_t state; ///< contains the last few bytes in MSB order
  170. int frame_start_found;
  171. int overread; ///< the number of bytes which where irreversibly read from the next frame
  172. int overread_index; ///< the index into ParseContext.buffer of the overreaded bytes
  173. } ParseContext;
  174. struct MpegEncContext;
  175. /**
  176. * Motion estimation context.
  177. */
  178. typedef struct MotionEstContext{
  179. AVCodecContext *avctx;
  180. int skip; ///< set if ME is skipped for the current MB
  181. int co_located_mv[4][2]; ///< mv from last p frame for direct mode ME
  182. int direct_basis_mv[4][2];
  183. uint8_t *scratchpad; ///< data area for the me algo, so that the ME doesnt need to malloc/free
  184. uint8_t *best_mb;
  185. uint8_t *temp_mb[2];
  186. uint8_t *temp;
  187. int best_bits;
  188. uint32_t *map; ///< map to avoid duplicate evaluations
  189. uint32_t *score_map; ///< map to store the scores
  190. int map_generation;
  191. int pre_penalty_factor;
  192. int penalty_factor;
  193. int sub_penalty_factor;
  194. int mb_penalty_factor;
  195. int flags;
  196. int sub_flags;
  197. int mb_flags;
  198. int pre_pass; ///< = 1 for the pre pass
  199. int dia_size;
  200. int xmin;
  201. int xmax;
  202. int ymin;
  203. int ymax;
  204. int pred_x;
  205. int pred_y;
  206. uint8_t *src[4][4];
  207. uint8_t *ref[4][4];
  208. int stride;
  209. int uvstride;
  210. /* temp variables for picture complexity calculation */
  211. int mc_mb_var_sum_temp;
  212. int mb_var_sum_temp;
  213. int scene_change_score;
  214. /* cmp, chroma_cmp;*/
  215. op_pixels_func (*hpel_put)[4];
  216. op_pixels_func (*hpel_avg)[4];
  217. qpel_mc_func (*qpel_put)[16];
  218. qpel_mc_func (*qpel_avg)[16];
  219. uint8_t (*mv_penalty)[MAX_MV*2+1]; ///< amount of bits needed to encode a MV
  220. uint8_t *current_mv_penalty;
  221. int (*sub_motion_search)(struct MpegEncContext * s,
  222. int *mx_ptr, int *my_ptr, int dmin,
  223. int src_index, int ref_index,
  224. int size, int h);
  225. }MotionEstContext;
  226. /**
  227. * MpegEncContext.
  228. */
  229. typedef struct MpegEncContext {
  230. struct AVCodecContext *avctx;
  231. /* the following parameters must be initialized before encoding */
  232. int width, height;///< picture size. must be a multiple of 16
  233. int gop_size;
  234. int intra_only; ///< if true, only intra pictures are generated
  235. int bit_rate; ///< wanted bit rate
  236. enum OutputFormat out_format; ///< output format
  237. int h263_pred; ///< use mpeg4/h263 ac/dc predictions
  238. /* the following codec id fields are deprecated in favor of codec_id */
  239. int h263_plus; ///< h263 plus headers
  240. int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
  241. int h263_flv; ///< use flv h263 header
  242. enum CodecID codec_id; /* see CODEC_ID_xxx */
  243. int fixed_qscale; ///< fixed qscale if non zero
  244. int encoding; ///< true if we are encoding (vs decoding)
  245. int flags; ///< AVCodecContext.flags (HQ, MV4, ...)
  246. int flags2; ///< AVCodecContext.flags2
  247. int max_b_frames; ///< max number of b-frames for encoding
  248. int luma_elim_threshold;
  249. int chroma_elim_threshold;
  250. int strict_std_compliance; ///< strictly follow the std (MPEG4, ...)
  251. int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically
  252. /* the following fields are managed internally by the encoder */
  253. /** bit output */
  254. PutBitContext pb;
  255. /* sequence parameters */
  256. int context_initialized;
  257. int input_picture_number; ///< used to set pic->display_picture_number, shouldnt be used for/by anything else
  258. int coded_picture_number; ///< used to set pic->coded_picture_number, shouldnt be used for/by anything else
  259. int picture_number; //FIXME remove, unclear definition
  260. int picture_in_gop_number; ///< 0-> first pic in gop, ...
  261. int b_frames_since_non_b; ///< used for encoding, relative to not yet reordered input
  262. int64_t user_specified_pts;///< last non zero pts from AVFrame which was passed into avcodec_encode_video()
  263. int mb_width, mb_height; ///< number of MBs horizontally & vertically
  264. int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11
  265. int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
  266. int b4_stride; ///< 4*mb_width+1 used for some 4x4 block arrays to allow simple addressing
  267. int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replication)
  268. int mb_num; ///< number of MBs of a picture
  269. int linesize; ///< line size, in bytes, may be different from width
  270. int uvlinesize; ///< line size, for chroma in bytes, may be different from width
  271. Picture *picture; ///< main picture buffer
  272. Picture **input_picture; ///< next pictures on display order for encoding
  273. Picture **reordered_input_picture; ///< pointer to the next pictures in codedorder for encoding
  274. int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
  275. int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
  276. struct MpegEncContext *thread_context[MAX_THREADS];
  277. /**
  278. * copy of the previous picture structure.
  279. * note, linesize & data, might not match the previous picture (for field pictures)
  280. */
  281. Picture last_picture;
  282. /**
  283. * copy of the next picture structure.
  284. * note, linesize & data, might not match the next picture (for field pictures)
  285. */
  286. Picture next_picture;
  287. /**
  288. * copy of the source picture structure for encoding.
  289. * note, linesize & data, might not match the source picture (for field pictures)
  290. */
  291. Picture new_picture;
  292. /**
  293. * copy of the current picture structure.
  294. * note, linesize & data, might not match the current picture (for field pictures)
  295. */
  296. Picture current_picture; ///< buffer to store the decompressed current picture
  297. Picture *last_picture_ptr; ///< pointer to the previous picture.
  298. Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred)
  299. Picture *current_picture_ptr; ///< pointer to the current picture
  300. uint8_t *visualization_buffer[3]; //< temporary buffer vor MV visualization
  301. int last_dc[3]; ///< last DC values for MPEG1
  302. int16_t *dc_val_base;
  303. int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous
  304. int16_t dc_cache[4*5];
  305. int y_dc_scale, c_dc_scale;
  306. const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table
  307. const uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table
  308. const uint8_t *chroma_qscale_table; ///< qscale -> chroma_qscale (h263)
  309. uint8_t *coded_block_base;
  310. uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
  311. int16_t (*ac_val_base)[16];
  312. int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous
  313. int ac_pred;
  314. uint8_t *prev_pict_types; ///< previous picture types in bitstream order, used for mb skip
  315. #define PREV_PICT_TYPES_BUFFER_SIZE 256
  316. int mb_skipped; ///< MUST BE SET only during DECODING
  317. uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example)
  318. and used for b-frame encoding & decoding (contains skip table of next P Frame) */
  319. uint8_t *mbintra_table; ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
  320. uint8_t *cbp_table; ///< used to store cbp, ac_pred for partitioned decoding
  321. uint8_t *pred_dir_table; ///< used to store pred_dir for partitioned decoding
  322. uint8_t *allocated_edge_emu_buffer;
  323. uint8_t *edge_emu_buffer; ///< points into the middle of allocated_edge_emu_buffer
  324. uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
  325. uint8_t *obmc_scratchpad;
  326. uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers
  327. int qscale; ///< QP
  328. int chroma_qscale; ///< chroma QP
  329. int lambda; ///< lagrange multipler used in rate distortion
  330. int lambda2; ///< (lambda*lambda) >> FF_LAMBDA_SHIFT
  331. int *lambda_table;
  332. int adaptive_quant; ///< use adaptive quantization
  333. int dquant; ///< qscale difference to prev qscale
  334. int pict_type; ///< I_TYPE, P_TYPE, B_TYPE, ...
  335. int last_pict_type; //FIXME removes
  336. int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol
  337. int dropable;
  338. int frame_rate_index;
  339. /* motion compensation */
  340. int unrestricted_mv; ///< mv can point outside of the coded picture
  341. int h263_long_vectors; ///< use horrible h263v1 long vector mode
  342. int decode; ///< if 0 then decoding will be skipped (for encoding b frames for example)
  343. DSPContext dsp; ///< pointers for accelerated dsp functions
  344. int f_code; ///< forward MV resolution
  345. int b_code; ///< backward MV resolution for B Frames (mpeg4)
  346. int16_t (*p_mv_table_base)[2];
  347. int16_t (*b_forw_mv_table_base)[2];
  348. int16_t (*b_back_mv_table_base)[2];
  349. int16_t (*b_bidir_forw_mv_table_base)[2];
  350. int16_t (*b_bidir_back_mv_table_base)[2];
  351. int16_t (*b_direct_mv_table_base)[2];
  352. int16_t (*p_field_mv_table_base[2][2])[2];
  353. int16_t (*b_field_mv_table_base[2][2][2])[2];
  354. int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) p-frame encoding
  355. int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode b-frame encoding
  356. int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode b-frame encoding
  357. int16_t (*b_bidir_forw_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
  358. int16_t (*b_bidir_back_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
  359. int16_t (*b_direct_mv_table)[2]; ///< MV table (1MV per MB) direct mode b-frame encoding
  360. int16_t (*p_field_mv_table[2][2])[2]; ///< MV table (2MV per MB) interlaced p-frame encoding
  361. int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding
  362. uint8_t (*p_field_select_table[2]);
  363. uint8_t (*b_field_select_table[2][2]);
  364. int me_method; ///< ME algorithm
  365. int mv_dir;
  366. #define MV_DIR_BACKWARD 1
  367. #define MV_DIR_FORWARD 2
  368. #define MV_DIRECT 4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
  369. int mv_type;
  370. #define MV_TYPE_16X16 0 ///< 1 vector for the whole mb
  371. #define MV_TYPE_8X8 1 ///< 4 vectors (h263, mpeg4 4MV)
  372. #define MV_TYPE_16X8 2 ///< 2 vectors, one per 16x8 block
  373. #define MV_TYPE_FIELD 3 ///< 2 vectors, one per field
  374. #define MV_TYPE_DMV 4 ///< 2 vectors, special mpeg2 Dual Prime Vectors
  375. /**motion vectors for a macroblock
  376. first coordinate : 0 = forward 1 = backward
  377. second " : depend on type
  378. third " : 0 = x, 1 = y
  379. */
  380. int mv[2][4][2];
  381. int field_select[2][2];
  382. int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4
  383. uint8_t *fcode_tab; ///< smallest fcode needed for each MV
  384. MotionEstContext me;
  385. int no_rounding; /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...)
  386. for b-frames rounding mode is allways 0 */
  387. int hurry_up; /**< when set to 1 during decoding, b frames will be skipped
  388. when set to 2 idct/dequant will be skipped too */
  389. /* macroblock layer */
  390. int mb_x, mb_y;
  391. int mb_skip_run;
  392. int mb_intra;
  393. uint16_t *mb_type; ///< Table for candidate MB types for encoding
  394. #define CANDIDATE_MB_TYPE_INTRA 0x01
  395. #define CANDIDATE_MB_TYPE_INTER 0x02
  396. #define CANDIDATE_MB_TYPE_INTER4V 0x04
  397. #define CANDIDATE_MB_TYPE_SKIPPED 0x08
  398. //#define MB_TYPE_GMC 0x10
  399. #define CANDIDATE_MB_TYPE_DIRECT 0x10
  400. #define CANDIDATE_MB_TYPE_FORWARD 0x20
  401. #define CANDIDATE_MB_TYPE_BACKWARD 0x40
  402. #define CANDIDATE_MB_TYPE_BIDIR 0x80
  403. #define CANDIDATE_MB_TYPE_INTER_I 0x100
  404. #define CANDIDATE_MB_TYPE_FORWARD_I 0x200
  405. #define CANDIDATE_MB_TYPE_BACKWARD_I 0x400
  406. #define CANDIDATE_MB_TYPE_BIDIR_I 0x800
  407. int block_index[6]; ///< index to current MB in block based arrays with edges
  408. int block_wrap[6];
  409. uint8_t *dest[3];
  410. int *mb_index2xy; ///< mb_index -> mb_x + mb_y*mb_stride
  411. /** matrix transmitted in the bitstream */
  412. uint16_t intra_matrix[64];
  413. uint16_t chroma_intra_matrix[64];
  414. uint16_t inter_matrix[64];
  415. uint16_t chroma_inter_matrix[64];
  416. #define QUANT_BIAS_SHIFT 8
  417. int intra_quant_bias; ///< bias for the quantizer
  418. int inter_quant_bias; ///< bias for the quantizer
  419. int min_qcoeff; ///< minimum encodable coefficient
  420. int max_qcoeff; ///< maximum encodable coefficient
  421. int ac_esc_length; ///< num of bits needed to encode the longest esc
  422. uint8_t *intra_ac_vlc_length;
  423. uint8_t *intra_ac_vlc_last_length;
  424. uint8_t *inter_ac_vlc_length;
  425. uint8_t *inter_ac_vlc_last_length;
  426. uint8_t *luma_dc_vlc_length;
  427. uint8_t *chroma_dc_vlc_length;
  428. #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
  429. int coded_score[6];
  430. /** precomputed matrix (combine qscale and DCT renorm) */
  431. int (*q_intra_matrix)[64];
  432. int (*q_inter_matrix)[64];
  433. /** identical to the above but for MMX & these are not permutated, second 64 entries are bias*/
  434. uint16_t (*q_intra_matrix16)[2][64];
  435. uint16_t (*q_inter_matrix16)[2][64];
  436. int block_last_index[12]; ///< last non zero coefficient in block
  437. /* scantables */
  438. ScanTable __align8 intra_scantable;
  439. ScanTable intra_h_scantable;
  440. ScanTable intra_v_scantable;
  441. ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
  442. /* noise reduction */
  443. int (*dct_error_sum)[64];
  444. int dct_count[2];
  445. uint16_t (*dct_offset)[64];
  446. void *opaque; ///< private data for the user
  447. /* bit rate control */
  448. int64_t wanted_bits;
  449. int64_t total_bits;
  450. int frame_bits; ///< bits used for the current frame
  451. RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
  452. /* statistics, used for 2-pass encoding */
  453. int mv_bits;
  454. int header_bits;
  455. int i_tex_bits;
  456. int p_tex_bits;
  457. int i_count;
  458. int f_count;
  459. int b_count;
  460. int skip_count;
  461. int misc_bits; ///< cbp, mb_type
  462. int last_bits; ///< temp var used for calculating the above vars
  463. /* error concealment / resync */
  464. int error_count;
  465. uint8_t *error_status_table; ///< table of the error status of each MB
  466. #define VP_START 1 ///< current MB is the first after a resync marker
  467. #define AC_ERROR 2
  468. #define DC_ERROR 4
  469. #define MV_ERROR 8
  470. #define AC_END 16
  471. #define DC_END 32
  472. #define MV_END 64
  473. //FIXME some prefix?
  474. int resync_mb_x; ///< x position of last resync marker
  475. int resync_mb_y; ///< y position of last resync marker
  476. GetBitContext last_resync_gb; ///< used to search for the next resync marker
  477. int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only)
  478. int next_p_frame_damaged; ///< set if the next p frame is damaged, to avoid showing trashed b frames
  479. int error_resilience;
  480. ParseContext parse_context;
  481. /* H.263 specific */
  482. int gob_index;
  483. int obmc; ///< overlapped block motion compensation
  484. /* H.263+ specific */
  485. int umvplus; ///< == H263+ && unrestricted_mv
  486. int h263_aic; ///< Advanded INTRA Coding (AIC)
  487. int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top
  488. int h263_slice_structured;
  489. int alt_inter_vlc; ///< alternative inter vlc
  490. int modified_quant;
  491. int loop_filter;
  492. int custom_pcf;
  493. /* mpeg4 specific */
  494. int time_increment_bits; ///< number of bits to represent the fractional part of time
  495. int last_time_base;
  496. int time_base; ///< time in seconds of last I,P,S Frame
  497. int64_t time; ///< time of current frame
  498. int64_t last_non_b_time;
  499. uint16_t pp_time; ///< time distance between the last 2 p,s,i frames
  500. uint16_t pb_time; ///< time distance between the last b and p,s,i frame
  501. uint16_t pp_field_time;
  502. uint16_t pb_field_time; ///< like above, just for interlaced
  503. int shape;
  504. int vol_sprite_usage;
  505. int sprite_width;
  506. int sprite_height;
  507. int sprite_left;
  508. int sprite_top;
  509. int sprite_brightness_change;
  510. int num_sprite_warping_points;
  511. int real_sprite_warping_points;
  512. int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY]
  513. int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY]
  514. int sprite_shift[2]; ///< sprite shift [isChroma]
  515. int mcsel;
  516. int quant_precision;
  517. int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
  518. int scalability;
  519. int hierachy_type;
  520. int enhancement_type;
  521. int new_pred;
  522. int reduced_res_vop;
  523. int aspect_ratio_info; //FIXME remove
  524. int sprite_warping_accuracy;
  525. int low_latency_sprite;
  526. int data_partitioning; ///< data partitioning flag from header
  527. int partitioned_frame; ///< is current frame partitioned
  528. int rvlc; ///< reversible vlc
  529. int resync_marker; ///< could this stream contain resync markers
  530. int low_delay; ///< no reordering needed / has no b-frames
  531. int vo_type;
  532. int vol_control_parameters; ///< does the stream contain the low_delay flag, used to workaround buggy encoders
  533. int intra_dc_threshold; ///< QP above whch the ac VLC should be used for intra dc
  534. PutBitContext tex_pb; ///< used for data partitioned VOPs
  535. PutBitContext pb2; ///< used for data partitioned VOPs
  536. int mpeg_quant;
  537. int t_frame; ///< time distance of first I -> B, used for interlaced b frames
  538. int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG4
  539. /* divx specific, used to workaround (many) bugs in divx5 */
  540. int divx_version;
  541. int divx_build;
  542. int divx_packed;
  543. uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
  544. int bitstream_buffer_size;
  545. int allocated_bitstream_buffer_size;
  546. int xvid_build;
  547. /* lavc specific stuff, used to workaround bugs in libavcodec */
  548. int ffmpeg_version;
  549. int lavc_build;
  550. /* RV10 specific */
  551. int rv10_version; ///< RV10 version: 0 or 3
  552. int rv10_first_dc_coded[3];
  553. /* MJPEG specific */
  554. struct MJpegContext *mjpeg_ctx;
  555. int mjpeg_vsample[3]; ///< vertical sampling factors, default = {2, 1, 1}
  556. int mjpeg_hsample[3]; ///< horizontal sampling factors, default = {2, 1, 1}
  557. int mjpeg_write_tables; ///< do we want to have quantisation- and huffmantables in the jpeg file ?
  558. int mjpeg_data_only_frames; ///< frames only with SOI, SOS and EOI markers
  559. /* MSMPEG4 specific */
  560. int mv_table_index;
  561. int rl_table_index;
  562. int rl_chroma_table_index;
  563. int dc_table_index;
  564. int use_skip_mb_code;
  565. int slice_height; ///< in macroblocks
  566. int first_slice_line; ///< used in mpeg4 too to handle resync markers
  567. int flipflop_rounding;
  568. int msmpeg4_version; ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
  569. int per_mb_rl_table;
  570. int esc3_level_length;
  571. int esc3_run_length;
  572. /** [mb_intra][isChroma][level][run][last] */
  573. int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
  574. int inter_intra_pred;
  575. int mspel;
  576. /* decompression specific */
  577. GetBitContext gb;
  578. /* Mpeg1 specific */
  579. int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific
  580. int last_mv_dir; ///< last mv_dir, used for b frame encoding
  581. int broken_link; ///< no_output_of_prior_pics_flag
  582. uint8_t *vbv_delay_ptr; ///< pointer to vbv_delay in the bitstream
  583. /* MPEG2 specific - I wish I had not to support this mess. */
  584. int progressive_sequence;
  585. int mpeg_f_code[2][2];
  586. int picture_structure;
  587. /* picture type */
  588. #define PICT_TOP_FIELD 1
  589. #define PICT_BOTTOM_FIELD 2
  590. #define PICT_FRAME 3
  591. int intra_dc_precision;
  592. int frame_pred_frame_dct;
  593. int top_field_first;
  594. int concealment_motion_vectors;
  595. int q_scale_type;
  596. int intra_vlc_format;
  597. int alternate_scan;
  598. int repeat_first_field;
  599. int chroma_420_type;
  600. int chroma_format;
  601. #define CHROMA_420 1
  602. #define CHROMA_422 2
  603. #define CHROMA_444 3
  604. int chroma_x_shift;//depend on pix_format, that depend on chroma_format
  605. int chroma_y_shift;
  606. int progressive_frame;
  607. int full_pel[2];
  608. int interlaced_dct;
  609. int first_slice;
  610. int first_field; ///< is 1 for the first field of a field picture 0 otherwise
  611. /* RTP specific */
  612. int rtp_mode;
  613. uint8_t *ptr_lastgob;
  614. int swap_uv;//vcr2 codec is mpeg2 varint with UV swaped
  615. short * pblocks[12];
  616. DCTELEM (*block)[64]; ///< points to one of the following blocks
  617. DCTELEM (*blocks)[6][64]; // for HQ mode we need to keep the best block
  618. int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
  619. #define SLICE_OK 0
  620. #define SLICE_ERROR -1
  621. #define SLICE_END -2 ///<end marker found
  622. #define SLICE_NOEND -3 ///<no end marker or error found but mb count exceeded
  623. void (*dct_unquantize_mpeg1_intra)(struct MpegEncContext *s,
  624. DCTELEM *block/*align 16*/, int n, int qscale);
  625. void (*dct_unquantize_mpeg1_inter)(struct MpegEncContext *s,
  626. DCTELEM *block/*align 16*/, int n, int qscale);
  627. void (*dct_unquantize_mpeg2_intra)(struct MpegEncContext *s,
  628. DCTELEM *block/*align 16*/, int n, int qscale);
  629. void (*dct_unquantize_mpeg2_inter)(struct MpegEncContext *s,
  630. DCTELEM *block/*align 16*/, int n, int qscale);
  631. void (*dct_unquantize_h263_intra)(struct MpegEncContext *s,
  632. DCTELEM *block/*align 16*/, int n, int qscale);
  633. void (*dct_unquantize_h263_inter)(struct MpegEncContext *s,
  634. DCTELEM *block/*align 16*/, int n, int qscale);
  635. void (*dct_unquantize_h261_intra)(struct MpegEncContext *s,
  636. DCTELEM *block/*align 16*/, int n, int qscale);
  637. void (*dct_unquantize_h261_inter)(struct MpegEncContext *s,
  638. DCTELEM *block/*align 16*/, int n, int qscale);
  639. void (*dct_unquantize_intra)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
  640. DCTELEM *block/*align 16*/, int n, int qscale);
  641. void (*dct_unquantize_inter)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
  642. DCTELEM *block/*align 16*/, int n, int qscale);
  643. int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
  644. int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
  645. void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block);
  646. } MpegEncContext;
  647. int DCT_common_init(MpegEncContext *s);
  648. void MPV_decode_defaults(MpegEncContext *s);
  649. int MPV_common_init(MpegEncContext *s);
  650. void MPV_common_end(MpegEncContext *s);
  651. void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]);
  652. int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
  653. void MPV_frame_end(MpegEncContext *s);
  654. int MPV_encode_init(AVCodecContext *avctx);
  655. int MPV_encode_end(AVCodecContext *avctx);
  656. int MPV_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data);
  657. #ifdef HAVE_MMX
  658. void MPV_common_init_mmx(MpegEncContext *s);
  659. #endif
  660. #ifdef ARCH_ALPHA
  661. void MPV_common_init_axp(MpegEncContext *s);
  662. #endif
  663. #ifdef HAVE_MLIB
  664. void MPV_common_init_mlib(MpegEncContext *s);
  665. #endif
  666. #ifdef HAVE_MMI
  667. void MPV_common_init_mmi(MpegEncContext *s);
  668. #endif
  669. #ifdef ARCH_ARMV4L
  670. void MPV_common_init_armv4l(MpegEncContext *s);
  671. #endif
  672. #ifdef ARCH_POWERPC
  673. void MPV_common_init_ppc(MpegEncContext *s);
  674. #endif
  675. extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
  676. void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
  677. void ff_clean_intra_table_entries(MpegEncContext *s);
  678. void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
  679. void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
  680. void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h,
  681. int src_x, int src_y, int w, int h);
  682. #define END_NOT_FOUND -100
  683. int ff_combine_frame(ParseContext *pc, int next, uint8_t **buf, int *buf_size);
  684. void ff_parse_close(AVCodecParserContext *s);
  685. void ff_mpeg_flush(AVCodecContext *avctx);
  686. void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
  687. void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix);
  688. int ff_find_unused_picture(MpegEncContext *s, int shared);
  689. void ff_denoise_dct(MpegEncContext *s, DCTELEM *block);
  690. void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
  691. void ff_er_frame_start(MpegEncContext *s);
  692. void ff_er_frame_end(MpegEncContext *s);
  693. void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status);
  694. extern enum PixelFormat ff_yuv420p_list[2];
  695. void ff_init_block_index(MpegEncContext *s);
  696. static inline void ff_update_block_index(MpegEncContext *s){
  697. const int block_size= 8>>s->avctx->lowres;
  698. s->block_index[0]+=2;
  699. s->block_index[1]+=2;
  700. s->block_index[2]+=2;
  701. s->block_index[3]+=2;
  702. s->block_index[4]++;
  703. s->block_index[5]++;
  704. s->dest[0]+= 2*block_size;
  705. s->dest[1]+= block_size;
  706. s->dest[2]+= block_size;
  707. }
  708. static inline int get_bits_diff(MpegEncContext *s){
  709. const int bits= put_bits_count(&s->pb);
  710. const int last= s->last_bits;
  711. s->last_bits = bits;
  712. return bits - last;
  713. }
  714. /* motion_est.c */
  715. void ff_estimate_p_frame_motion(MpegEncContext * s,
  716. int mb_x, int mb_y);
  717. void ff_estimate_b_frame_motion(MpegEncContext * s,
  718. int mb_x, int mb_y);
  719. int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
  720. void ff_fix_long_p_mvs(MpegEncContext * s);
  721. void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select,
  722. int16_t (*mv_table)[2], int f_code, int type, int truncate);
  723. void ff_init_me(MpegEncContext *s);
  724. int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
  725. inline int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
  726. int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
  727. int ref_mv_scale, int size, int h);
  728. int inline ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
  729. int ref_index, int size, int h, int add_rate);
  730. /* mpeg12.c */
  731. extern const int16_t ff_mpeg1_default_intra_matrix[64];
  732. extern const int16_t ff_mpeg1_default_non_intra_matrix[64];
  733. extern const uint8_t ff_mpeg1_dc_scale_table[128];
  734. void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
  735. void mpeg1_encode_mb(MpegEncContext *s,
  736. DCTELEM block[6][64],
  737. int motion_x, int motion_y);
  738. void ff_mpeg1_encode_init(MpegEncContext *s);
  739. void ff_mpeg1_encode_slice_header(MpegEncContext *s);
  740. void ff_mpeg1_clean_buffers(MpegEncContext *s);
  741. int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
  742. /** RLTable. */
  743. typedef struct RLTable {
  744. int n; ///< number of entries of table_vlc minus 1
  745. int last; ///< number of values for last = 0
  746. const uint16_t (*table_vlc)[2];
  747. const int8_t *table_run;
  748. const int8_t *table_level;
  749. uint8_t *index_run[2]; ///< encoding only
  750. int8_t *max_level[2]; ///< encoding & decoding
  751. int8_t *max_run[2]; ///< encoding & decoding
  752. VLC vlc; ///< decoding only deprected FIXME remove
  753. RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
  754. } RLTable;
  755. void init_rl(RLTable *rl, int use_static);
  756. void init_vlc_rl(RLTable *rl, int use_static);
  757. static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
  758. {
  759. int index;
  760. index = rl->index_run[last][run];
  761. if (index >= rl->n)
  762. return rl->n;
  763. if (level > rl->max_level[last][run])
  764. return rl->n;
  765. return index + level - 1;
  766. }
  767. extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
  768. extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
  769. extern const uint8_t ff_aic_dc_scale_table[32];
  770. extern const int16_t ff_mpeg4_default_intra_matrix[64];
  771. extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
  772. extern const uint8_t ff_h263_chroma_qscale_table[32];
  773. extern const uint8_t ff_h263_loop_filter_strength[32];
  774. /* h261.c */
  775. void ff_h261_loop_filter(MpegEncContext *s);
  776. void ff_h261_reorder_mb_index(MpegEncContext* s);
  777. void ff_h261_encode_mb(MpegEncContext *s,
  778. DCTELEM block[6][64],
  779. int motion_x, int motion_y);
  780. void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number);
  781. void ff_h261_encode_init(MpegEncContext *s);
  782. /* h263.c, h263dec.c */
  783. int ff_h263_decode_init(AVCodecContext *avctx);
  784. int ff_h263_decode_frame(AVCodecContext *avctx,
  785. void *data, int *data_size,
  786. uint8_t *buf, int buf_size);
  787. int ff_h263_decode_end(AVCodecContext *avctx);
  788. void h263_encode_mb(MpegEncContext *s,
  789. DCTELEM block[6][64],
  790. int motion_x, int motion_y);
  791. void mpeg4_encode_mb(MpegEncContext *s,
  792. DCTELEM block[6][64],
  793. int motion_x, int motion_y);
  794. void h263_encode_picture_header(MpegEncContext *s, int picture_number);
  795. void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number);
  796. void h263_encode_gob_header(MpegEncContext * s, int mb_line);
  797. int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
  798. int *px, int *py);
  799. void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
  800. int dir);
  801. void ff_set_mpeg4_time(MpegEncContext * s, int picture_number);
  802. void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
  803. void h263_encode_init(MpegEncContext *s);
  804. void h263_decode_init_vlc(MpegEncContext *s);
  805. int h263_decode_picture_header(MpegEncContext *s);
  806. int ff_h263_decode_gob_header(MpegEncContext *s);
  807. int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
  808. void ff_h263_update_motion_val(MpegEncContext * s);
  809. void ff_h263_loop_filter(MpegEncContext * s);
  810. void ff_set_qscale(MpegEncContext * s, int qscale);
  811. int ff_h263_decode_mba(MpegEncContext *s);
  812. void ff_h263_encode_mba(MpegEncContext *s);
  813. int intel_h263_decode_picture_header(MpegEncContext *s);
  814. int flv_h263_decode_picture_header(MpegEncContext *s);
  815. int ff_h263_decode_mb(MpegEncContext *s,
  816. DCTELEM block[6][64]);
  817. int ff_mpeg4_decode_mb(MpegEncContext *s,
  818. DCTELEM block[6][64]);
  819. int h263_get_picture_format(int width, int height);
  820. void ff_mpeg4_encode_video_packet_header(MpegEncContext *s);
  821. void ff_mpeg4_clean_buffers(MpegEncContext *s);
  822. void ff_mpeg4_stuffing(PutBitContext * pbc);
  823. void ff_mpeg4_init_partitions(MpegEncContext *s);
  824. void ff_mpeg4_merge_partitions(MpegEncContext *s);
  825. void ff_clean_mpeg4_qscales(MpegEncContext *s);
  826. void ff_clean_h263_qscales(MpegEncContext *s);
  827. int ff_mpeg4_decode_partitions(MpegEncContext *s);
  828. int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
  829. int ff_h263_resync(MpegEncContext *s);
  830. int ff_h263_get_gob_height(MpegEncContext *s);
  831. int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
  832. int ff_h263_round_chroma(int x);
  833. void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
  834. int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
  835. /* rv10.c */
  836. void rv10_encode_picture_header(MpegEncContext *s, int picture_number);
  837. int rv_decode_dc(MpegEncContext *s, int n);
  838. void rv20_encode_picture_header(MpegEncContext *s, int picture_number);
  839. /* msmpeg4.c */
  840. void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
  841. void msmpeg4_encode_ext_header(MpegEncContext * s);
  842. void msmpeg4_encode_mb(MpegEncContext * s,
  843. DCTELEM block[6][64],
  844. int motion_x, int motion_y);
  845. int msmpeg4_decode_picture_header(MpegEncContext * s);
  846. int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
  847. int ff_msmpeg4_decode_init(MpegEncContext *s);
  848. void ff_msmpeg4_encode_init(MpegEncContext *s);
  849. int ff_wmv2_decode_picture_header(MpegEncContext * s);
  850. int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
  851. void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
  852. void ff_mspel_motion(MpegEncContext *s,
  853. uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
  854. uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
  855. int motion_x, int motion_y, int h);
  856. int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
  857. void ff_wmv2_encode_mb(MpegEncContext * s,
  858. DCTELEM block[6][64],
  859. int motion_x, int motion_y);
  860. /* mjpeg.c */
  861. int mjpeg_init(MpegEncContext *s);
  862. void mjpeg_close(MpegEncContext *s);
  863. void mjpeg_encode_mb(MpegEncContext *s,
  864. DCTELEM block[6][64]);
  865. void mjpeg_picture_header(MpegEncContext *s);
  866. void mjpeg_picture_trailer(MpegEncContext *s);
  867. void ff_mjpeg_stuffing(PutBitContext * pbc);
  868. /* rate control */
  869. int ff_rate_control_init(MpegEncContext *s);
  870. float ff_rate_estimate_qscale(MpegEncContext *s);
  871. void ff_write_pass1_stats(MpegEncContext *s);
  872. void ff_rate_control_uninit(MpegEncContext *s);
  873. double ff_eval(char *s, double *const_value, const char **const_name,
  874. double (**func1)(void *, double), const char **func1_name,
  875. double (**func2)(void *, double, double), char **func2_name,
  876. void *opaque);
  877. int ff_vbv_update(MpegEncContext *s, int frame_size);
  878. #endif /* AVCODEC_MPEGVIDEO_H */