注:写了一系列的结构体的分析的文章,在这里列一个列表:

FFMPEG结构体分析:AVFrame
FFMPEG结构体分析:AVFormatContext
FFMPEG结构体分析:AVCodecContext
FFMPEG结构体分析:AVIOContext
FFMPEG结构体分析:AVCodec
FFMPEG结构体分析:AVStream
FFMPEG结构体分析:AVPacket

FFMPEG有几个最重要的结构体,包含了解协议,解封装,解码操作,此前已经进行过分析:

FFMPEG中最关键的结构体之间的关系

在此不再详述,其中AVCodecContext是包含变量较多的结构体(感觉差不多是变量最多的结构体)。本文将会大概分析一下该结构体里每个变量的含义和作用。因为如果每个变量都分析的话,工作量太大,实在来不及。

首先看一下结构体的定义(位于avcodec.h):

[cpp] view plaincopy
  1. /*
  2. *雷霄骅
  3. *leixiaohua1020@126.com
  4. *中国传媒大学/数字电视技术
  5. */
  6. /**
  7. * main external API structure.
  8. * New fields can be added to the end with minor version bumps.
  9. * Removal, reordering and changes to existing fields require a major
  10. * version bump.
  11. * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
  12. * applications.
  13. * sizeof(AVCodecContext) must not be used outside libav*.
  14. */
  15. typedef struct AVCodecContext {
  16. /**
  17. * information on struct for av_log
  18. * - set by avcodec_alloc_context3
  19. */
  20. const AVClass *av_class;
  21. int log_level_offset;
  22. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
  23. const struct AVCodec  *codec;
  24. char             codec_name[32];
  25. enum AVCodecID     codec_id; /* see AV_CODEC_ID_xxx */
  26. /**
  27. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  28. * This is used to work around some encoder bugs.
  29. * A demuxer should set this to what is stored in the field used to identify the codec.
  30. * If there are multiple such fields in a container then the demuxer should choose the one
  31. * which maximizes the information about the used codec.
  32. * If the codec tag field in a container is larger than 32 bits then the demuxer should
  33. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
  34. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
  35. * first.
  36. * - encoding: Set by user, if not then the default based on codec_id will be used.
  37. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  38. */
  39. unsigned int codec_tag;
  40. /**
  41. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  42. * This is used to work around some encoder bugs.
  43. * - encoding: unused
  44. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
  45. */
  46. unsigned int stream_codec_tag;
  47. #if FF_API_SUB_ID
  48. /**
  49. * @deprecated this field is unused
  50. */
  51. attribute_deprecated int sub_id;
  52. #endif
  53. void *priv_data;
  54. /**
  55. * Private context used for internal data.
  56. *
  57. * Unlike priv_data, this is not codec-specific. It is used in general
  58. * libavcodec functions.
  59. */
  60. struct AVCodecInternal *internal;
  61. /**
  62. * Private data of the user, can be used to carry app specific stuff.
  63. * - encoding: Set by user.
  64. * - decoding: Set by user.
  65. */
  66. void *opaque;
  67. /**
  68. * the average bitrate
  69. * - encoding: Set by user; unused for constant quantizer encoding.
  70. * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
  71. */
  72. int bit_rate;
  73. /**
  74. * number of bits the bitstream is allowed to diverge from the reference.
  75. *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
  76. * - encoding: Set by user; unused for constant quantizer encoding.
  77. * - decoding: unused
  78. */
  79. int bit_rate_tolerance;
  80. /**
  81. * Global quality for codecs which cannot change it per frame.
  82. * This should be proportional to MPEG-1/2/4 qscale.
  83. * - encoding: Set by user.
  84. * - decoding: unused
  85. */
  86. int global_quality;
  87. /**
  88. * - encoding: Set by user.
  89. * - decoding: unused
  90. */
  91. int compression_level;
  92. #define FF_COMPRESSION_DEFAULT -1
  93. /**
  94. * CODEC_FLAG_*.
  95. * - encoding: Set by user.
  96. * - decoding: Set by user.
  97. */
  98. int flags;
  99. /**
  100. * CODEC_FLAG2_*
  101. * - encoding: Set by user.
  102. * - decoding: Set by user.
  103. */
  104. int flags2;
  105. /**
  106. * some codecs need / can use extradata like Huffman tables.
  107. * mjpeg: Huffman tables
  108. * rv10: additional flags
  109. * mpeg4: global headers (they can be in the bitstream or here)
  110. * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  111. * than extradata_size to avoid prolems if it is read with the bitstream reader.
  112. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
  113. * - encoding: Set/allocated/freed by libavcodec.
  114. * - decoding: Set/allocated/freed by user.
  115. */
  116. uint8_t *extradata;
  117. int extradata_size;
  118. /**
  119. * This is the fundamental unit of time (in seconds) in terms
  120. * of which frame timestamps are represented. For fixed-fps content,
  121. * timebase should be 1/framerate and timestamp increments should be
  122. * identically 1.
  123. * - encoding: MUST be set by user.
  124. * - decoding: Set by libavcodec.
  125. */
  126. AVRational time_base;
  127. /**
  128. * For some codecs, the time base is closer to the field rate than the frame rate.
  129. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
  130. * if no telecine is used ...
  131. *
  132. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
  133. */
  134. int ticks_per_frame;
  135. /**
  136. * Encoding: Number of frames delay there will be from the encoder input to
  137. *           the decoder output. (we assume the decoder matches the spec)
  138. * Decoding: Number of frames delay in addition to what a standard decoder
  139. *           as specified in the spec would produce.
  140. *
  141. * Video:
  142. *   Number of frames the decoded output will be delayed relative to the
  143. *   encoded input.
  144. *
  145. * Audio:
  146. *   For encoding, this is the number of "priming" samples added to the
  147. *   beginning of the stream. The decoded output will be delayed by this
  148. *   many samples relative to the input to the encoder. Note that this
  149. *   field is purely informational and does not directly affect the pts
  150. *   output by the encoder, which should always be based on the actual
  151. *   presentation time, including any delay.
  152. *   For decoding, this is the number of samples the decoder needs to
  153. *   output before the decoder's output is valid. When seeking, you should
  154. *   start decoding this many samples prior to your desired seek point.
  155. *
  156. * - encoding: Set by libavcodec.
  157. * - decoding: Set by libavcodec.
  158. */
  159. int delay;
  160. /* video only */
  161. /**
  162. * picture width / height.
  163. * - encoding: MUST be set by user.
  164. * - decoding: Set by libavcodec.
  165. * Note: For compatibility it is possible to set this instead of
  166. * coded_width/height before decoding.
  167. */
  168. int width, height;
  169. /**
  170. * Bitstream width / height, may be different from width/height if lowres enabled.
  171. * - encoding: unused
  172. * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
  173. */
  174. int coded_width, coded_height;
  175. #define FF_ASPECT_EXTENDED 15
  176. /**
  177. * the number of pictures in a group of pictures, or 0 for intra_only
  178. * - encoding: Set by user.
  179. * - decoding: unused
  180. */
  181. int gop_size;
  182. /**
  183. * Pixel format, see AV_PIX_FMT_xxx.
  184. * May be set by the demuxer if known from headers.
  185. * May be overridden by the decoder if it knows better.
  186. * - encoding: Set by user.
  187. * - decoding: Set by user if known, overridden by libavcodec if known
  188. */
  189. enum AVPixelFormat pix_fmt;
  190. /**
  191. * Motion estimation algorithm used for video coding.
  192. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  193. * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
  194. * - encoding: MUST be set by user.
  195. * - decoding: unused
  196. */
  197. int me_method;
  198. /**
  199. * If non NULL, 'draw_horiz_band' is called by the libavcodec
  200. * decoder to draw a horizontal band. It improves cache usage. Not
  201. * all codecs can do that. You must check the codec capabilities
  202. * beforehand.
  203. * When multithreading is used, it may be called from multiple threads
  204. * at the same time; threads might draw different parts of the same AVFrame,
  205. * or multiple AVFrames, and there is no guarantee that slices will be drawn
  206. * in order.
  207. * The function is also used by hardware acceleration APIs.
  208. * It is called at least once during frame decoding to pass
  209. * the data needed for hardware render.
  210. * In that mode instead of pixel data, AVFrame points to
  211. * a structure specific to the acceleration API. The application
  212. * reads the structure and can change some fields to indicate progress
  213. * or mark state.
  214. * - encoding: unused
  215. * - decoding: Set by user.
  216. * @param height the height of the slice
  217. * @param y the y position of the slice
  218. * @param type 1->top field, 2->bottom field, 3->frame
  219. * @param offset offset into the AVFrame.data from which the slice should be read
  220. */
  221. void (*draw_horiz_band)(struct AVCodecContext *s,
  222. const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
  223. int y, int type, int height);
  224. /**
  225. * callback to negotiate the pixelFormat
  226. * @param fmt is the list of formats which are supported by the codec,
  227. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
  228. * The first is always the native one.
  229. * @return the chosen format
  230. * - encoding: unused
  231. * - decoding: Set by user, if not set the native format will be chosen.
  232. */
  233. enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
  234. /**
  235. * maximum number of B-frames between non-B-frames
  236. * Note: The output will be delayed by max_b_frames+1 relative to the input.
  237. * - encoding: Set by user.
  238. * - decoding: unused
  239. */
  240. int max_b_frames;
  241. /**
  242. * qscale factor between IP and B-frames
  243. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
  244. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  245. * - encoding: Set by user.
  246. * - decoding: unused
  247. */
  248. float b_quant_factor;
  249. /** obsolete FIXME remove */
  250. int rc_strategy;
  251. #define FF_RC_STRATEGY_XVID 1
  252. int b_frame_strategy;
  253. #if FF_API_MPV_GLOBAL_OPTS
  254. /**
  255. * luma single coefficient elimination threshold
  256. * - encoding: Set by user.
  257. * - decoding: unused
  258. */
  259. attribute_deprecated int luma_elim_threshold;
  260. /**
  261. * chroma single coeff elimination threshold
  262. * - encoding: Set by user.
  263. * - decoding: unused
  264. */
  265. attribute_deprecated int chroma_elim_threshold;
  266. #endif
  267. /**
  268. * qscale offset between IP and B-frames
  269. * - encoding: Set by user.
  270. * - decoding: unused
  271. */
  272. float b_quant_offset;
  273. /**
  274. * Size of the frame reordering buffer in the decoder.
  275. * For MPEG-2 it is 1 IPB or 0 low delay IP.
  276. * - encoding: Set by libavcodec.
  277. * - decoding: Set by libavcodec.
  278. */
  279. int has_b_frames;
  280. /**
  281. * 0-> h263 quant 1-> mpeg quant
  282. * - encoding: Set by user.
  283. * - decoding: unused
  284. */
  285. int mpeg_quant;
  286. /**
  287. * qscale factor between P and I-frames
  288. * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
  289. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
  290. * - encoding: Set by user.
  291. * - decoding: unused
  292. */
  293. float i_quant_factor;
  294. /**
  295. * qscale offset between P and I-frames
  296. * - encoding: Set by user.
  297. * - decoding: unused
  298. */
  299. float i_quant_offset;
  300. /**
  301. * luminance masking (0-> disabled)
  302. * - encoding: Set by user.
  303. * - decoding: unused
  304. */
  305. float lumi_masking;
  306. /**
  307. * temporary complexity masking (0-> disabled)
  308. * - encoding: Set by user.
  309. * - decoding: unused
  310. */
  311. float temporal_cplx_masking;
  312. /**
  313. * spatial complexity masking (0-> disabled)
  314. * - encoding: Set by user.
  315. * - decoding: unused
  316. */
  317. float spatial_cplx_masking;
  318. /**
  319. * p block masking (0-> disabled)
  320. * - encoding: Set by user.
  321. * - decoding: unused
  322. */
  323. float p_masking;
  324. /**
  325. * darkness masking (0-> disabled)
  326. * - encoding: Set by user.
  327. * - decoding: unused
  328. */
  329. float dark_masking;
  330. /**
  331. * slice count
  332. * - encoding: Set by libavcodec.
  333. * - decoding: Set by user (or 0).
  334. */
  335. int slice_count;
  336. /**
  337. * prediction method (needed for huffyuv)
  338. * - encoding: Set by user.
  339. * - decoding: unused
  340. */
  341. int prediction_method;
  342. #define FF_PRED_LEFT   0
  343. #define FF_PRED_PLANE  1
  344. #define FF_PRED_MEDIAN 2
  345. /**
  346. * slice offsets in the frame in bytes
  347. * - encoding: Set/allocated by libavcodec.
  348. * - decoding: Set/allocated by user (or NULL).
  349. */
  350. int *slice_offset;
  351. /**
  352. * sample aspect ratio (0 if unknown)
  353. * That is the width of a pixel divided by the height of the pixel.
  354. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
  355. * - encoding: Set by user.
  356. * - decoding: Set by libavcodec.
  357. */
  358. AVRational sample_aspect_ratio;
  359. /**
  360. * motion estimation comparison function
  361. * - encoding: Set by user.
  362. * - decoding: unused
  363. */
  364. int me_cmp;
  365. /**
  366. * subpixel motion estimation comparison function
  367. * - encoding: Set by user.
  368. * - decoding: unused
  369. */
  370. int me_sub_cmp;
  371. /**
  372. * macroblock comparison function (not supported yet)
  373. * - encoding: Set by user.
  374. * - decoding: unused
  375. */
  376. int mb_cmp;
  377. /**
  378. * interlaced DCT comparison function
  379. * - encoding: Set by user.
  380. * - decoding: unused
  381. */
  382. int ildct_cmp;
  383. #define FF_CMP_SAD    0
  384. #define FF_CMP_SSE    1
  385. #define FF_CMP_SATD   2
  386. #define FF_CMP_DCT    3
  387. #define FF_CMP_PSNR   4
  388. #define FF_CMP_BIT    5
  389. #define FF_CMP_RD     6
  390. #define FF_CMP_ZERO   7
  391. #define FF_CMP_VSAD   8
  392. #define FF_CMP_VSSE   9
  393. #define FF_CMP_NSSE   10
  394. #define FF_CMP_W53    11
  395. #define FF_CMP_W97    12
  396. #define FF_CMP_DCTMAX 13
  397. #define FF_CMP_DCT264 14
  398. #define FF_CMP_CHROMA 256
  399. /**
  400. * ME diamond size & shape
  401. * - encoding: Set by user.
  402. * - decoding: unused
  403. */
  404. int dia_size;
  405. /**
  406. * amount of previous MV predictors (2a+1 x 2a+1 square)
  407. * - encoding: Set by user.
  408. * - decoding: unused
  409. */
  410. int last_predictor_count;
  411. /**
  412. * prepass for motion estimation
  413. * - encoding: Set by user.
  414. * - decoding: unused
  415. */
  416. int pre_me;
  417. /**
  418. * motion estimation prepass comparison function
  419. * - encoding: Set by user.
  420. * - decoding: unused
  421. */
  422. int me_pre_cmp;
  423. /**
  424. * ME prepass diamond size & shape
  425. * - encoding: Set by user.
  426. * - decoding: unused
  427. */
  428. int pre_dia_size;
  429. /**
  430. * subpel ME quality
  431. * - encoding: Set by user.
  432. * - decoding: unused
  433. */
  434. int me_subpel_quality;
  435. /**
  436. * DTG active format information (additional aspect ratio
  437. * information only used in DVB MPEG-2 transport streams)
  438. * 0 if not set.
  439. *
  440. * - encoding: unused
  441. * - decoding: Set by decoder.
  442. */
  443. int dtg_active_format;
  444. #define FF_DTG_AFD_SAME         8
  445. #define FF_DTG_AFD_4_3          9
  446. #define FF_DTG_AFD_16_9         10
  447. #define FF_DTG_AFD_14_9         11
  448. #define FF_DTG_AFD_4_3_SP_14_9  13
  449. #define FF_DTG_AFD_16_9_SP_14_9 14
  450. #define FF_DTG_AFD_SP_4_3       15
  451. /**
  452. * maximum motion estimation search range in subpel units
  453. * If 0 then no limit.
  454. *
  455. * - encoding: Set by user.
  456. * - decoding: unused
  457. */
  458. int me_range;
  459. /**
  460. * intra quantizer bias
  461. * - encoding: Set by user.
  462. * - decoding: unused
  463. */
  464. int intra_quant_bias;
  465. #define FF_DEFAULT_QUANT_BIAS 999999
  466. /**
  467. * inter quantizer bias
  468. * - encoding: Set by user.
  469. * - decoding: unused
  470. */
  471. int inter_quant_bias;
  472. #if FF_API_COLOR_TABLE_ID
  473. /**
  474. * color table ID
  475. * - encoding: unused
  476. * - decoding: Which clrtable should be used for 8bit RGB images.
  477. *             Tables have to be stored somewhere. FIXME
  478. */
  479. attribute_deprecated int color_table_id;
  480. #endif
  481. /**
  482. * slice flags
  483. * - encoding: unused
  484. * - decoding: Set by user.
  485. */
  486. int slice_flags;
  487. #define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
  488. #define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  489. #define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  490. /**
  491. * XVideo Motion Acceleration
  492. * - encoding: forbidden
  493. * - decoding: set by decoder
  494. */
  495. int xvmc_acceleration;
  496. /**
  497. * macroblock decision mode
  498. * - encoding: Set by user.
  499. * - decoding: unused
  500. */
  501. int mb_decision;
  502. #define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
  503. #define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
  504. #define FF_MB_DECISION_RD     2        ///< rate distortion
  505. /**
  506. * custom intra quantization matrix
  507. * - encoding: Set by user, can be NULL.
  508. * - decoding: Set by libavcodec.
  509. */
  510. uint16_t *intra_matrix;
  511. /**
  512. * custom inter quantization matrix
  513. * - encoding: Set by user, can be NULL.
  514. * - decoding: Set by libavcodec.
  515. */
  516. uint16_t *inter_matrix;
  517. /**
  518. * scene change detection threshold
  519. * 0 is default, larger means fewer detected scene changes.
  520. * - encoding: Set by user.
  521. * - decoding: unused
  522. */
  523. int scenechange_threshold;
  524. /**
  525. * noise reduction strength
  526. * - encoding: Set by user.
  527. * - decoding: unused
  528. */
  529. int noise_reduction;
  530. #if FF_API_INTER_THRESHOLD
  531. /**
  532. * @deprecated this field is unused
  533. */
  534. attribute_deprecated int inter_threshold;
  535. #endif
  536. #if FF_API_MPV_GLOBAL_OPTS
  537. /**
  538. * @deprecated use mpegvideo private options instead
  539. */
  540. attribute_deprecated int quantizer_noise_shaping;
  541. #endif
  542. /**
  543. * Motion estimation threshold below which no motion estimation is
  544. * performed, but instead the user specified motion vectors are used.
  545. *
  546. * - encoding: Set by user.
  547. * - decoding: unused
  548. */
  549. int me_threshold;
  550. /**
  551. * Macroblock threshold below which the user specified macroblock types will be used.
  552. * - encoding: Set by user.
  553. * - decoding: unused
  554. */
  555. int mb_threshold;
  556. /**
  557. * precision of the intra DC coefficient - 8
  558. * - encoding: Set by user.
  559. * - decoding: unused
  560. */
  561. int intra_dc_precision;
  562. /**
  563. * Number of macroblock rows at the top which are skipped.
  564. * - encoding: unused
  565. * - decoding: Set by user.
  566. */
  567. int skip_top;
  568. /**
  569. * Number of macroblock rows at the bottom which are skipped.
  570. * - encoding: unused
  571. * - decoding: Set by user.
  572. */
  573. int skip_bottom;
  574. /**
  575. * Border processing masking, raises the quantizer for mbs on the borders
  576. * of the picture.
  577. * - encoding: Set by user.
  578. * - decoding: unused
  579. */
  580. float border_masking;
  581. /**
  582. * minimum MB lagrange multipler
  583. * - encoding: Set by user.
  584. * - decoding: unused
  585. */
  586. int mb_lmin;
  587. /**
  588. * maximum MB lagrange multipler
  589. * - encoding: Set by user.
  590. * - decoding: unused
  591. */
  592. int mb_lmax;
  593. /**
  594. *
  595. * - encoding: Set by user.
  596. * - decoding: unused
  597. */
  598. int me_penalty_compensation;
  599. /**
  600. *
  601. * - encoding: Set by user.
  602. * - decoding: unused
  603. */
  604. int bidir_refine;
  605. /**
  606. *
  607. * - encoding: Set by user.
  608. * - decoding: unused
  609. */
  610. int brd_scale;
  611. /**
  612. * minimum GOP size
  613. * - encoding: Set by user.
  614. * - decoding: unused
  615. */
  616. int keyint_min;
  617. /**
  618. * number of reference frames
  619. * - encoding: Set by user.
  620. * - decoding: Set by lavc.
  621. */
  622. int refs;
  623. /**
  624. * chroma qp offset from luma
  625. * - encoding: Set by user.
  626. * - decoding: unused
  627. */
  628. int chromaoffset;
  629. /**
  630. * Multiplied by qscale for each frame and added to scene_change_score.
  631. * - encoding: Set by user.
  632. * - decoding: unused
  633. */
  634. int scenechange_factor;
  635. /**
  636. *
  637. * Note: Value depends upon the compare function used for fullpel ME.
  638. * - encoding: Set by user.
  639. * - decoding: unused
  640. */
  641. int mv0_threshold;
  642. /**
  643. * Adjust sensitivity of b_frame_strategy 1.
  644. * - encoding: Set by user.
  645. * - decoding: unused
  646. */
  647. int b_sensitivity;
  648. /**
  649. * Chromaticity coordinates of the source primaries.
  650. * - encoding: Set by user
  651. * - decoding: Set by libavcodec
  652. */
  653. enum AVColorPrimaries color_primaries;
  654. /**
  655. * Color Transfer Characteristic.
  656. * - encoding: Set by user
  657. * - decoding: Set by libavcodec
  658. */
  659. enum AVColorTransferCharacteristic color_trc;
  660. /**
  661. * YUV colorspace type.
  662. * - encoding: Set by user
  663. * - decoding: Set by libavcodec
  664. */
  665. enum AVColorSpace colorspace;
  666. /**
  667. * MPEG vs JPEG YUV range.
  668. * - encoding: Set by user
  669. * - decoding: Set by libavcodec
  670. */
  671. enum AVColorRange color_range;
  672. /**
  673. * This defines the location of chroma samples.
  674. * - encoding: Set by user
  675. * - decoding: Set by libavcodec
  676. */
  677. enum AVChromaLocation chroma_sample_location;
  678. /**
  679. * Number of slices.
  680. * Indicates number of picture subdivisions. Used for parallelized
  681. * decoding.
  682. * - encoding: Set by user
  683. * - decoding: unused
  684. */
  685. int slices;
  686. /** Field order
  687. * - encoding: set by libavcodec
  688. * - decoding: Set by user.
  689. */
  690. enum AVFieldOrder field_order;
  691. /* audio only */
  692. int sample_rate; ///< samples per second
  693. int channels;    ///< number of audio channels
  694. /**
  695. * audio sample format
  696. * - encoding: Set by user.
  697. * - decoding: Set by libavcodec.
  698. */
  699. enum AVSampleFormat sample_fmt;  ///< sample format
  700. /* The following data should not be initialized. */
  701. /**
  702. * Samples per packet, initialized when calling 'init'.
  703. */
  704. int frame_size;
  705. /**
  706. * Frame counter, set by libavcodec.
  707. *
  708. * - decoding: total number of frames returned from the decoder so far.
  709. * - encoding: total number of frames passed to the encoder so far.
  710. *
  711. *   @note the counter is not incremented if encoding/decoding resulted in
  712. *   an error.
  713. */
  714. int frame_number;
  715. /**
  716. * number of bytes per packet if constant and known or 0
  717. * Used by some WAV based audio codecs.
  718. */
  719. int block_align;
  720. /**
  721. * Audio cutoff bandwidth (0 means "automatic")
  722. * - encoding: Set by user.
  723. * - decoding: unused
  724. */
  725. int cutoff;
  726. #if FF_API_REQUEST_CHANNELS
  727. /**
  728. * Decoder should decode to this many channels if it can (0 for default)
  729. * - encoding: unused
  730. * - decoding: Set by user.
  731. * @deprecated Deprecated in favor of request_channel_layout.
  732. */
  733. int request_channels;
  734. #endif
  735. /**
  736. * Audio channel layout.
  737. * - encoding: set by user.
  738. * - decoding: set by user, may be overwritten by libavcodec.
  739. */
  740. uint64_t channel_layout;
  741. /**
  742. * Request decoder to use this channel layout if it can (0 for default)
  743. * - encoding: unused
  744. * - decoding: Set by user.
  745. */
  746. uint64_t request_channel_layout;
  747. /**
  748. * Type of service that the audio stream conveys.
  749. * - encoding: Set by user.
  750. * - decoding: Set by libavcodec.
  751. */
  752. enum AVAudioServiceType audio_service_type;
  753. /**
  754. * desired sample format
  755. * - encoding: Not used.
  756. * - decoding: Set by user.
  757. * Decoder will decode to this format if it can.
  758. */
  759. enum AVSampleFormat request_sample_fmt;
  760. /**
  761. * Called at the beginning of each frame to get a buffer for it.
  762. *
  763. * The function will set AVFrame.data[], AVFrame.linesize[].
  764. * AVFrame.extended_data[] must also be set, but it should be the same as
  765. * AVFrame.data[] except for planar audio with more channels than can fit
  766. * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
  767. * many data pointers as it can hold.
  768. *
  769. * if CODEC_CAP_DR1 is not set then get_buffer() must call
  770. * avcodec_default_get_buffer() instead of providing buffers allocated by
  771. * some other means.
  772. *
  773. * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
  774. * need it. avcodec_default_get_buffer() aligns the output buffer properly,
  775. * but if get_buffer() is overridden then alignment considerations should
  776. * be taken into account.
  777. *
  778. * @see avcodec_default_get_buffer()
  779. *
  780. * Video:
  781. *
  782. * If pic.reference is set then the frame will be read later by libavcodec.
  783. * avcodec_align_dimensions2() should be used to find the required width and
  784. * height, as they normally need to be rounded up to the next multiple of 16.
  785. *
  786. * If frame multithreading is used and thread_safe_callbacks is set,
  787. * it may be called from a different thread, but not from more than one at
  788. * once. Does not need to be reentrant.
  789. *
  790. * @see release_buffer(), reget_buffer()
  791. * @see avcodec_align_dimensions2()
  792. *
  793. * Audio:
  794. *
  795. * Decoders request a buffer of a particular size by setting
  796. * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
  797. * however, utilize only part of the buffer by setting AVFrame.nb_samples
  798. * to a smaller value in the output frame.
  799. *
  800. * Decoders cannot use the buffer after returning from
  801. * avcodec_decode_audio4(), so they will not call release_buffer(), as it
  802. * is assumed to be released immediately upon return.
  803. *
  804. * As a convenience, av_samples_get_buffer_size() and
  805. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
  806. * functions to find the required data size and to fill data pointers and
  807. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
  808. * since all planes must be the same size.
  809. *
  810. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
  811. *
  812. * - encoding: unused
  813. * - decoding: Set by libavcodec, user can override.
  814. */
  815. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  816. /**
  817. * Called to release buffers which were allocated with get_buffer.
  818. * A released buffer can be reused in get_buffer().
  819. * pic.data[*] must be set to NULL.
  820. * May be called from a different thread if frame multithreading is used,
  821. * but not by more than one thread at once, so does not need to be reentrant.
  822. * - encoding: unused
  823. * - decoding: Set by libavcodec, user can override.
  824. */
  825. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  826. /**
  827. * Called at the beginning of a frame to get cr buffer for it.
  828. * Buffer type (size, hints) must be the same. libavcodec won't check it.
  829. * libavcodec will pass previous buffer in pic, function should return
  830. * same buffer or new buffer with old frame "painted" into it.
  831. * If pic.data[0] == NULL must behave like get_buffer().
  832. * if CODEC_CAP_DR1 is not set then reget_buffer() must call
  833. * avcodec_default_reget_buffer() instead of providing buffers allocated by
  834. * some other means.
  835. * - encoding: unused
  836. * - decoding: Set by libavcodec, user can override.
  837. */
  838. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  839. /* - encoding parameters */
  840. float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  841. float qblur;      ///< amount of qscale smoothing over time (0.0-1.0)
  842. /**
  843. * minimum quantizer
  844. * - encoding: Set by user.
  845. * - decoding: unused
  846. */
  847. int qmin;
  848. /**
  849. * maximum quantizer
  850. * - encoding: Set by user.
  851. * - decoding: unused
  852. */
  853. int qmax;
  854. /**
  855. * maximum quantizer difference between frames
  856. * - encoding: Set by user.
  857. * - decoding: unused
  858. */
  859. int max_qdiff;
  860. /**
  861. * ratecontrol qmin qmax limiting method
  862. * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
  863. * - encoding: Set by user.
  864. * - decoding: unused
  865. */
  866. float rc_qsquish;
  867. float rc_qmod_amp;
  868. int rc_qmod_freq;
  869. /**
  870. * decoder bitstream buffer size
  871. * - encoding: Set by user.
  872. * - decoding: unused
  873. */
  874. int rc_buffer_size;
  875. /**
  876. * ratecontrol override, see RcOverride
  877. * - encoding: Allocated/set/freed by user.
  878. * - decoding: unused
  879. */
  880. int rc_override_count;
  881. RcOverride *rc_override;
  882. /**
  883. * rate control equation
  884. * - encoding: Set by user
  885. * - decoding: unused
  886. */
  887. const char *rc_eq;
  888. /**
  889. * maximum bitrate
  890. * - encoding: Set by user.
  891. * - decoding: unused
  892. */
  893. int rc_max_rate;
  894. /**
  895. * minimum bitrate
  896. * - encoding: Set by user.
  897. * - decoding: unused
  898. */
  899. int rc_min_rate;
  900. float rc_buffer_aggressivity;
  901. /**
  902. * initial complexity for pass1 ratecontrol
  903. * - encoding: Set by user.
  904. * - decoding: unused
  905. */
  906. float rc_initial_cplx;
  907. /**
  908. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
  909. * - encoding: Set by user.
  910. * - decoding: unused.
  911. */
  912. float rc_max_available_vbv_use;
  913. /**
  914. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
  915. * - encoding: Set by user.
  916. * - decoding: unused.
  917. */
  918. float rc_min_vbv_overflow_use;
  919. /**
  920. * Number of bits which should be loaded into the rc buffer before decoding starts.
  921. * - encoding: Set by user.
  922. * - decoding: unused
  923. */
  924. int rc_initial_buffer_occupancy;
  925. #define FF_CODER_TYPE_VLC       0
  926. #define FF_CODER_TYPE_AC        1
  927. #define FF_CODER_TYPE_RAW       2
  928. #define FF_CODER_TYPE_RLE       3
  929. #define FF_CODER_TYPE_DEFLATE   4
  930. /**
  931. * coder type
  932. * - encoding: Set by user.
  933. * - decoding: unused
  934. */
  935. int coder_type;
  936. /**
  937. * context model
  938. * - encoding: Set by user.
  939. * - decoding: unused
  940. */
  941. int context_model;
  942. /**
  943. * minimum Lagrange multipler
  944. * - encoding: Set by user.
  945. * - decoding: unused
  946. */
  947. int lmin;
  948. /**
  949. * maximum Lagrange multipler
  950. * - encoding: Set by user.
  951. * - decoding: unused
  952. */
  953. int lmax;
  954. /**
  955. * frame skip threshold
  956. * - encoding: Set by user.
  957. * - decoding: unused
  958. */
  959. int frame_skip_threshold;
  960. /**
  961. * frame skip factor
  962. * - encoding: Set by user.
  963. * - decoding: unused
  964. */
  965. int frame_skip_factor;
  966. /**
  967. * frame skip exponent
  968. * - encoding: Set by user.
  969. * - decoding: unused
  970. */
  971. int frame_skip_exp;
  972. /**
  973. * frame skip comparison function
  974. * - encoding: Set by user.
  975. * - decoding: unused
  976. */
  977. int frame_skip_cmp;
  978. /**
  979. * trellis RD quantization
  980. * - encoding: Set by user.
  981. * - decoding: unused
  982. */
  983. int trellis;
  984. /**
  985. * - encoding: Set by user.
  986. * - decoding: unused
  987. */
  988. int min_prediction_order;
  989. /**
  990. * - encoding: Set by user.
  991. * - decoding: unused
  992. */
  993. int max_prediction_order;
  994. /**
  995. * GOP timecode frame start number
  996. * - encoding: Set by user, in non drop frame format
  997. * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
  998. */
  999. int64_t timecode_frame_start;
  1000. /* The RTP callback: This function is called    */
  1001. /* every time the encoder has a packet to send. */
  1002. /* It depends on the encoder if the data starts */
  1003. /* with a Start Code (it should). H.263 does.   */
  1004. /* mb_nb contains the number of macroblocks     */
  1005. /* encoded in the RTP payload.                  */
  1006. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  1007. int rtp_payload_size;   /* The size of the RTP payload: the coder will  */
  1008. /* do its best to deliver a chunk with size     */
  1009. /* below rtp_payload_size, the chunk will start */
  1010. /* with a start code on some codecs like H.263. */
  1011. /* This doesn't take account of any particular  */
  1012. /* headers inside the transmitted RTP payload.  */
  1013. /* statistics, used for 2-pass encoding */
  1014. int mv_bits;
  1015. int header_bits;
  1016. int i_tex_bits;
  1017. int p_tex_bits;
  1018. int i_count;
  1019. int p_count;
  1020. int skip_count;
  1021. int misc_bits;
  1022. /**
  1023. * number of bits used for the previously encoded frame
  1024. * - encoding: Set by libavcodec.
  1025. * - decoding: unused
  1026. */
  1027. int frame_bits;
  1028. /**
  1029. * pass1 encoding statistics output buffer
  1030. * - encoding: Set by libavcodec.
  1031. * - decoding: unused
  1032. */
  1033. char *stats_out;
  1034. /**
  1035. * pass2 encoding statistics input buffer
  1036. * Concatenated stuff from stats_out of pass1 should be placed here.
  1037. * - encoding: Allocated/set/freed by user.
  1038. * - decoding: unused
  1039. */
  1040. char *stats_in;
  1041. /**
  1042. * Work around bugs in encoders which sometimes cannot be detected automatically.
  1043. * - encoding: Set by user
  1044. * - decoding: Set by user
  1045. */
  1046. int workaround_bugs;
  1047. #define FF_BUG_AUTODETECT       1  ///< autodetection
  1048. #define FF_BUG_OLD_MSMPEG4      2
  1049. #define FF_BUG_XVID_ILACE       4
  1050. #define FF_BUG_UMP4             8
  1051. #define FF_BUG_NO_PADDING       16
  1052. #define FF_BUG_AMV              32
  1053. #define FF_BUG_AC_VLC           0  ///< Will be removed, libavcodec can now handle these non-compliant files by default.
  1054. #define FF_BUG_QPEL_CHROMA      64
  1055. #define FF_BUG_STD_QPEL         128
  1056. #define FF_BUG_QPEL_CHROMA2     256
  1057. #define FF_BUG_DIRECT_BLOCKSIZE 512
  1058. #define FF_BUG_EDGE             1024
  1059. #define FF_BUG_HPEL_CHROMA      2048
  1060. #define FF_BUG_DC_CLIP          4096
  1061. #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders.
  1062. #define FF_BUG_TRUNCATED       16384
  1063. /**
  1064. * strictly follow the standard (MPEG4, ...).
  1065. * - encoding: Set by user.
  1066. * - decoding: Set by user.
  1067. * Setting this to STRICT or higher means the encoder and decoder will
  1068. * generally do stupid things, whereas setting it to unofficial or lower
  1069. * will mean the encoder might produce output that is not supported by all
  1070. * spec-compliant decoders. Decoders don't differentiate between normal,
  1071. * unofficial and experimental (that is, they always try to decode things
  1072. * when they can) unless they are explicitly asked to behave stupidly
  1073. * (=strictly conform to the specs)
  1074. */
  1075. int strict_std_compliance;
  1076. #define FF_COMPLIANCE_VERY_STRICT   2 ///< Strictly conform to an older more strict version of the spec or reference software.
  1077. #define FF_COMPLIANCE_STRICT        1 ///< Strictly conform to all the things in the spec no matter what consequences.
  1078. #define FF_COMPLIANCE_NORMAL        0
  1079. #define FF_COMPLIANCE_UNOFFICIAL   -1 ///< Allow unofficial extensions
  1080. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
  1081. /**
  1082. * error concealment flags
  1083. * - encoding: unused
  1084. * - decoding: Set by user.
  1085. */
  1086. int error_concealment;
  1087. #define FF_EC_GUESS_MVS   1
  1088. #define FF_EC_DEBLOCK     2
  1089. /**
  1090. * debug
  1091. * - encoding: Set by user.
  1092. * - decoding: Set by user.
  1093. */
  1094. int debug;
  1095. #define FF_DEBUG_PICT_INFO   1
  1096. #define FF_DEBUG_RC          2
  1097. #define FF_DEBUG_BITSTREAM   4
  1098. #define FF_DEBUG_MB_TYPE     8
  1099. #define FF_DEBUG_QP          16
  1100. #define FF_DEBUG_MV          32
  1101. #define FF_DEBUG_DCT_COEFF   0x00000040
  1102. #define FF_DEBUG_SKIP        0x00000080
  1103. #define FF_DEBUG_STARTCODE   0x00000100
  1104. #define FF_DEBUG_PTS         0x00000200
  1105. #define FF_DEBUG_ER          0x00000400
  1106. #define FF_DEBUG_MMCO        0x00000800
  1107. #define FF_DEBUG_BUGS        0x00001000
  1108. #define FF_DEBUG_VIS_QP      0x00002000
  1109. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1110. #define FF_DEBUG_BUFFERS     0x00008000
  1111. #define FF_DEBUG_THREADS     0x00010000
  1112. /**
  1113. * debug
  1114. * - encoding: Set by user.
  1115. * - decoding: Set by user.
  1116. */
  1117. int debug_mv;
  1118. #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 //visualize forward predicted MVs of P frames
  1119. #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames
  1120. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1121. /**
  1122. * Error recognition; may misdetect some more or less valid parts as errors.
  1123. * - encoding: unused
  1124. * - decoding: Set by user.
  1125. */
  1126. int err_recognition;
  1127. #define AV_EF_CRCCHECK  (1<<0)
  1128. #define AV_EF_BITSTREAM (1<<1)
  1129. #define AV_EF_BUFFER    (1<<2)
  1130. #define AV_EF_EXPLODE   (1<<3)
  1131. #define AV_EF_CAREFUL    (1<<16)
  1132. #define AV_EF_COMPLIANT  (1<<17)
  1133. #define AV_EF_AGGRESSIVE (1<<18)
  1134. /**
  1135. * opaque 64bit number (generally a PTS) that will be reordered and
  1136. * output in AVFrame.reordered_opaque
  1137. * @deprecated in favor of pkt_pts
  1138. * - encoding: unused
  1139. * - decoding: Set by user.
  1140. */
  1141. int64_t reordered_opaque;
  1142. /**
  1143. * Hardware accelerator in use
  1144. * - encoding: unused.
  1145. * - decoding: Set by libavcodec
  1146. */
  1147. struct AVHWAccel *hwaccel;
  1148. /**
  1149. * Hardware accelerator context.
  1150. * For some hardware accelerators, a global context needs to be
  1151. * provided by the user. In that case, this holds display-dependent
  1152. * data FFmpeg cannot instantiate itself. Please refer to the
  1153. * FFmpeg HW accelerator documentation to know how to fill this
  1154. * is. e.g. for VA API, this is a struct vaapi_context.
  1155. * - encoding: unused
  1156. * - decoding: Set by user
  1157. */
  1158. void *hwaccel_context;
  1159. /**
  1160. * error
  1161. * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
  1162. * - decoding: unused
  1163. */
  1164. uint64_t error[AV_NUM_DATA_POINTERS];
  1165. /**
  1166. * DCT algorithm, see FF_DCT_* below
  1167. * - encoding: Set by user.
  1168. * - decoding: unused
  1169. */
  1170. int dct_algo;
  1171. #define FF_DCT_AUTO    0
  1172. #define FF_DCT_FASTINT 1
  1173. #define FF_DCT_INT     2
  1174. #define FF_DCT_MMX     3
  1175. #define FF_DCT_ALTIVEC 5
  1176. #define FF_DCT_FAAN    6
  1177. /**
  1178. * IDCT algorithm, see FF_IDCT_* below.
  1179. * - encoding: Set by user.
  1180. * - decoding: Set by user.
  1181. */
  1182. int idct_algo;
  1183. #define FF_IDCT_AUTO          0
  1184. #define FF_IDCT_INT           1
  1185. #define FF_IDCT_SIMPLE        2
  1186. #define FF_IDCT_SIMPLEMMX     3
  1187. #define FF_IDCT_LIBMPEG2MMX   4
  1188. #define FF_IDCT_MMI           5
  1189. #define FF_IDCT_ARM           7
  1190. #define FF_IDCT_ALTIVEC       8
  1191. #define FF_IDCT_SH4           9
  1192. #define FF_IDCT_SIMPLEARM     10
  1193. #define FF_IDCT_H264          11
  1194. #define FF_IDCT_VP3           12
  1195. #define FF_IDCT_IPP           13
  1196. #define FF_IDCT_XVIDMMX       14
  1197. #define FF_IDCT_CAVS          15
  1198. #define FF_IDCT_SIMPLEARMV5TE 16
  1199. #define FF_IDCT_SIMPLEARMV6   17
  1200. #define FF_IDCT_SIMPLEVIS     18
  1201. #define FF_IDCT_WMV2          19
  1202. #define FF_IDCT_FAAN          20
  1203. #define FF_IDCT_EA            21
  1204. #define FF_IDCT_SIMPLENEON    22
  1205. #define FF_IDCT_SIMPLEALPHA   23
  1206. #define FF_IDCT_BINK          24
  1207. #if FF_API_DSP_MASK
  1208. /**
  1209. * Unused.
  1210. * @deprecated use av_set_cpu_flags_mask() instead.
  1211. */
  1212. attribute_deprecated unsigned dsp_mask;
  1213. #endif
  1214. /**
  1215. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1216. * - encoding: Set by libavcodec.
  1217. * - decoding: Set by user.
  1218. */
  1219. int bits_per_coded_sample;
  1220. /**
  1221. * Bits per sample/pixel of internal libavcodec pixel/sample format.
  1222. * - encoding: set by user.
  1223. * - decoding: set by libavcodec.
  1224. */
  1225. int bits_per_raw_sample;
  1226. /**
  1227. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
  1228. * - encoding: unused
  1229. * - decoding: Set by user.
  1230. */
  1231. int lowres;
  1232. /**
  1233. * the picture in the bitstream
  1234. * - encoding: Set by libavcodec.
  1235. * - decoding: Set by libavcodec.
  1236. */
  1237. AVFrame *coded_frame;
  1238. /**
  1239. * thread count
  1240. * is used to decide how many independent tasks should be passed to execute()
  1241. * - encoding: Set by user.
  1242. * - decoding: Set by user.
  1243. */
  1244. int thread_count;
  1245. /**
  1246. * Which multithreading methods to use.
  1247. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
  1248. * so clients which cannot provide future frames should not use it.
  1249. *
  1250. * - encoding: Set by user, otherwise the default is used.
  1251. * - decoding: Set by user, otherwise the default is used.
  1252. */
  1253. int thread_type;
  1254. #define FF_THREAD_FRAME   1 ///< Decode more than one frame at once
  1255. #define FF_THREAD_SLICE   2 ///< Decode more than one part of a single frame at once
  1256. /**
  1257. * Which multithreading methods are in use by the codec.
  1258. * - encoding: Set by libavcodec.
  1259. * - decoding: Set by libavcodec.
  1260. */
  1261. int active_thread_type;
  1262. /**
  1263. * Set by the client if its custom get_buffer() callback can be called
  1264. * synchronously from another thread, which allows faster multithreaded decoding.
  1265. * draw_horiz_band() will be called from other threads regardless of this setting.
  1266. * Ignored if the default get_buffer() is used.
  1267. * - encoding: Set by user.
  1268. * - decoding: Set by user.
  1269. */
  1270. int thread_safe_callbacks;
  1271. /**
  1272. * The codec may call this to execute several independent things.
  1273. * It will return only after finishing all tasks.
  1274. * The user may replace this with some multithreaded implementation,
  1275. * the default implementation will execute the parts serially.
  1276. * @param count the number of things to execute
  1277. * - encoding: Set by libavcodec, user can override.
  1278. * - decoding: Set by libavcodec, user can override.
  1279. */
  1280. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
  1281. /**
  1282. * The codec may call this to execute several independent things.
  1283. * It will return only after finishing all tasks.
  1284. * The user may replace this with some multithreaded implementation,
  1285. * the default implementation will execute the parts serially.
  1286. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
  1287. * @param c context passed also to func
  1288. * @param count the number of things to execute
  1289. * @param arg2 argument passed unchanged to func
  1290. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
  1291. * @param func function that will be called count times, with jobnr from 0 to count-1.
  1292. *             threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
  1293. *             two instances of func executing at the same time will have the same threadnr.
  1294. * @return always 0 currently, but code should handle a future improvement where when any call to func
  1295. *         returns < 0 no further calls to func may be done and < 0 is returned.
  1296. * - encoding: Set by libavcodec, user can override.
  1297. * - decoding: Set by libavcodec, user can override.
  1298. */
  1299. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
  1300. /**
  1301. * thread opaque
  1302. * Can be used by execute() to store some per AVCodecContext stuff.
  1303. * - encoding: set by execute()
  1304. * - decoding: set by execute()
  1305. */
  1306. void *thread_opaque;
  1307. /**
  1308. * noise vs. sse weight for the nsse comparsion function
  1309. * - encoding: Set by user.
  1310. * - decoding: unused
  1311. */
  1312. int nsse_weight;
  1313. /**
  1314. * profile
  1315. * - encoding: Set by user.
  1316. * - decoding: Set by libavcodec.
  1317. */
  1318. int profile;
  1319. #define FF_PROFILE_UNKNOWN -99
  1320. #define FF_PROFILE_RESERVED -100
  1321. #define FF_PROFILE_AAC_MAIN 0
  1322. #define FF_PROFILE_AAC_LOW  1
  1323. #define FF_PROFILE_AAC_SSR  2
  1324. #define FF_PROFILE_AAC_LTP  3
  1325. #define FF_PROFILE_AAC_HE   4
  1326. #define FF_PROFILE_AAC_HE_V2 28
  1327. #define FF_PROFILE_AAC_LD   22
  1328. #define FF_PROFILE_AAC_ELD  38
  1329. #define FF_PROFILE_DTS         20
  1330. #define FF_PROFILE_DTS_ES      30
  1331. #define FF_PROFILE_DTS_96_24   40
  1332. #define FF_PROFILE_DTS_HD_HRA  50
  1333. #define FF_PROFILE_DTS_HD_MA   60
  1334. #define FF_PROFILE_MPEG2_422    0
  1335. #define FF_PROFILE_MPEG2_HIGH   1
  1336. #define FF_PROFILE_MPEG2_SS     2
  1337. #define FF_PROFILE_MPEG2_SNR_SCALABLE  3
  1338. #define FF_PROFILE_MPEG2_MAIN   4
  1339. #define FF_PROFILE_MPEG2_SIMPLE 5
  1340. #define FF_PROFILE_H264_CONSTRAINED  (1<<9)  // 8+1; constraint_set1_flag
  1341. #define FF_PROFILE_H264_INTRA        (1<<11) // 8+3; constraint_set3_flag
  1342. #define FF_PROFILE_H264_BASELINE             66
  1343. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
  1344. #define FF_PROFILE_H264_MAIN                 77
  1345. #define FF_PROFILE_H264_EXTENDED             88
  1346. #define FF_PROFILE_H264_HIGH                 100
  1347. #define FF_PROFILE_H264_HIGH_10              110
  1348. #define FF_PROFILE_H264_HIGH_10_INTRA        (110|FF_PROFILE_H264_INTRA)
  1349. #define FF_PROFILE_H264_HIGH_422             122
  1350. #define FF_PROFILE_H264_HIGH_422_INTRA       (122|FF_PROFILE_H264_INTRA)
  1351. #define FF_PROFILE_H264_HIGH_444             144
  1352. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE  244
  1353. #define FF_PROFILE_H264_HIGH_444_INTRA       (244|FF_PROFILE_H264_INTRA)
  1354. #define FF_PROFILE_H264_CAVLC_444            44
  1355. #define FF_PROFILE_VC1_SIMPLE   0
  1356. #define FF_PROFILE_VC1_MAIN     1
  1357. #define FF_PROFILE_VC1_COMPLEX  2
  1358. #define FF_PROFILE_VC1_ADVANCED 3
  1359. #define FF_PROFILE_MPEG4_SIMPLE                     0
  1360. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE            1
  1361. #define FF_PROFILE_MPEG4_CORE                       2
  1362. #define FF_PROFILE_MPEG4_MAIN                       3
  1363. #define FF_PROFILE_MPEG4_N_BIT                      4
  1364. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE           5
  1365. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION      6
  1366. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE     7
  1367. #define FF_PROFILE_MPEG4_HYBRID                     8
  1368. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME         9
  1369. #define FF_PROFILE_MPEG4_CORE_SCALABLE             10
  1370. #define FF_PROFILE_MPEG4_ADVANCED_CODING           11
  1371. #define FF_PROFILE_MPEG4_ADVANCED_CORE             12
  1372. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  1373. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO             14
  1374. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE           15
  1375. /**
  1376. * level
  1377. * - encoding: Set by user.
  1378. * - decoding: Set by libavcodec.
  1379. */
  1380. int level;
  1381. #define FF_LEVEL_UNKNOWN -99
  1382. /**
  1383. *
  1384. * - encoding: unused
  1385. * - decoding: Set by user.
  1386. */
  1387. enum AVDiscard skip_loop_filter;
  1388. /**
  1389. *
  1390. * - encoding: unused
  1391. * - decoding: Set by user.
  1392. */
  1393. enum AVDiscard skip_idct;
  1394. /**
  1395. *
  1396. * - encoding: unused
  1397. * - decoding: Set by user.
  1398. */
  1399. enum AVDiscard skip_frame;
  1400. /**
  1401. * Header containing style information for text subtitles.
  1402. * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
  1403. * [Script Info] and [V4+ Styles] section, plus the [Events] line and
  1404. * the Format line following. It shouldn't include any Dialogue line.
  1405. * - encoding: Set/allocated/freed by user (before avcodec_open2())
  1406. * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
  1407. */
  1408. uint8_t *subtitle_header;
  1409. int subtitle_header_size;
  1410. /**
  1411. * Simulates errors in the bitstream to test error concealment.
  1412. * - encoding: Set by user.
  1413. * - decoding: unused
  1414. */
  1415. int error_rate;
  1416. /**
  1417. * Current packet as passed into the decoder, to avoid having
  1418. * to pass the packet into every function. Currently only valid
  1419. * inside lavc and get/release_buffer callbacks.
  1420. * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
  1421. * - encoding: unused
  1422. */
  1423. AVPacket *pkt;
  1424. /**
  1425. * VBV delay coded in the last frame (in periods of a 27 MHz clock).
  1426. * Used for compliant TS muxing.
  1427. * - encoding: Set by libavcodec.
  1428. * - decoding: unused.
  1429. */
  1430. uint64_t vbv_delay;
  1431. /**
  1432. * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
  1433. * Code outside libavcodec should access this field using:
  1434. * avcodec_set_pkt_timebase(avctx)
  1435. * - encoding unused.
  1436. * - decodimg set by user
  1437. */
  1438. AVRational pkt_timebase;
  1439. /**
  1440. * AVCodecDescriptor
  1441. * Code outside libavcodec should access this field using:
  1442. * avcodec_get_codec_descriptior(avctx)
  1443. * - encoding: unused.
  1444. * - decoding: set by libavcodec.
  1445. */
  1446. const AVCodecDescriptor *codec_descriptor;
  1447. /**
  1448. * Current statistics for PTS correction.
  1449. * - decoding: maintained and used by libavcodec, not intended to be used by user apps
  1450. * - encoding: unused
  1451. */
  1452. int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
  1453. int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
  1454. int64_t pts_correction_last_pts;       /// PTS of the last frame
  1455. int64_t pts_correction_last_dts;       /// DTS of the last frame
  1456. } AVCodecContext;

光定义就真是够多的。下面挑一些关键的变量来看看(这里只考虑解码)。

enum AVMediaType codec_type:编解码器的类型(视频,音频...)

struct AVCodec  *codec:采用的解码器AVCodec(H.264,MPEG2...)

int bit_rate:平均比特率

uint8_t *extradata; int extradata_size:针对特定编码器包含的附加信息(例如对于H.264解码器来说,存储SPS,PPS等)

AVRational time_base:根据该参数,可以把PTS转化为实际的时间(单位为秒s)

int width, height:如果是视频的话,代表宽和高

int refs:运动估计参考帧的个数(H.264的话会有多帧,MPEG2这类的一般就没有了)

int sample_rate:采样率(音频)

int channels:声道数(音频)

enum AVSampleFormat sample_fmt:采样格式

int profile:型(H.264里面就有,其他编码标准应该也有)

int level:级(和profile差不太多)

在这里需要注意:AVCodecContext中很多的参数是编码的时候使用的,而不是解码的时候使用的。

其实这些参数都比较容易理解。就不多费篇幅了。在这里看一下以下几个参数:

1.codec_type

编解码器类型有以下几种:

[cpp] view plaincopy
  1. enum AVMediaType {
  2. AVMEDIA_TYPE_UNKNOWN = -1,  ///< Usually treated as AVMEDIA_TYPE_DATA
  3. AVMEDIA_TYPE_VIDEO,
  4. AVMEDIA_TYPE_AUDIO,
  5. AVMEDIA_TYPE_DATA,          ///< Opaque data information usually continuous
  6. AVMEDIA_TYPE_SUBTITLE,
  7. AVMEDIA_TYPE_ATTACHMENT,    ///< Opaque data information usually sparse
  8. AVMEDIA_TYPE_NB
  9. };

2.sample_fmt

在FFMPEG中音频采样格式有以下几种:

[cpp] view plaincopy
  1. enum AVSampleFormat {
  2. AV_SAMPLE_FMT_NONE = -1,
  3. AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
  4. AV_SAMPLE_FMT_S16,         ///< signed 16 bits
  5. AV_SAMPLE_FMT_S32,         ///< signed 32 bits
  6. AV_SAMPLE_FMT_FLT,         ///< float
  7. AV_SAMPLE_FMT_DBL,         ///< double
  8. AV_SAMPLE_FMT_U8P,         ///< unsigned 8 bits, planar
  9. AV_SAMPLE_FMT_S16P,        ///< signed 16 bits, planar
  10. AV_SAMPLE_FMT_S32P,        ///< signed 32 bits, planar
  11. AV_SAMPLE_FMT_FLTP,        ///< float, planar
  12. AV_SAMPLE_FMT_DBLP,        ///< double, planar
  13. AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
  14. };

3.profile

在FFMPEG中型有以下几种,可以看出AAC,MPEG2,H.264,VC-1,MPEG4都有型的概念。

[cpp] view plaincopy
  1. #define FF_PROFILE_UNKNOWN -99
  2. #define FF_PROFILE_RESERVED -100
  3. #define FF_PROFILE_AAC_MAIN 0
  4. #define FF_PROFILE_AAC_LOW  1
  5. #define FF_PROFILE_AAC_SSR  2
  6. #define FF_PROFILE_AAC_LTP  3
  7. #define FF_PROFILE_AAC_HE   4
  8. #define FF_PROFILE_AAC_HE_V2 28
  9. #define FF_PROFILE_AAC_LD   22
  10. #define FF_PROFILE_AAC_ELD  38
  11. #define FF_PROFILE_DTS         20
  12. #define FF_PROFILE_DTS_ES      30
  13. #define FF_PROFILE_DTS_96_24   40
  14. #define FF_PROFILE_DTS_HD_HRA  50
  15. #define FF_PROFILE_DTS_HD_MA   60
  16. #define FF_PROFILE_MPEG2_422    0
  17. #define FF_PROFILE_MPEG2_HIGH   1
  18. #define FF_PROFILE_MPEG2_SS     2
  19. #define FF_PROFILE_MPEG2_SNR_SCALABLE  3
  20. #define FF_PROFILE_MPEG2_MAIN   4
  21. #define FF_PROFILE_MPEG2_SIMPLE 5
  22. #define FF_PROFILE_H264_CONSTRAINED  (1<<9)  // 8+1; constraint_set1_flag
  23. #define FF_PROFILE_H264_INTRA        (1<<11) // 8+3; constraint_set3_flag
  24. #define FF_PROFILE_H264_BASELINE             66
  25. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
  26. #define FF_PROFILE_H264_MAIN                 77
  27. #define FF_PROFILE_H264_EXTENDED             88
  28. #define FF_PROFILE_H264_HIGH                 100
  29. #define FF_PROFILE_H264_HIGH_10              110
  30. #define FF_PROFILE_H264_HIGH_10_INTRA        (110|FF_PROFILE_H264_INTRA)
  31. #define FF_PROFILE_H264_HIGH_422             122
  32. #define FF_PROFILE_H264_HIGH_422_INTRA       (122|FF_PROFILE_H264_INTRA)
  33. #define FF_PROFILE_H264_HIGH_444             144
  34. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE  244
  35. #define FF_PROFILE_H264_HIGH_444_INTRA       (244|FF_PROFILE_H264_INTRA)
  36. #define FF_PROFILE_H264_CAVLC_444            44
  37. #define FF_PROFILE_VC1_SIMPLE   0
  38. #define FF_PROFILE_VC1_MAIN     1
  39. #define FF_PROFILE_VC1_COMPLEX  2
  40. #define FF_PROFILE_VC1_ADVANCED 3
  41. #define FF_PROFILE_MPEG4_SIMPLE                     0
  42. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE            1
  43. #define FF_PROFILE_MPEG4_CORE                       2
  44. #define FF_PROFILE_MPEG4_MAIN                       3
  45. #define FF_PROFILE_MPEG4_N_BIT                      4
  46. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE           5
  47. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION      6
  48. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE     7
  49. #define FF_PROFILE_MPEG4_HYBRID                     8
  50. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME         9
  51. #define FF_PROFILE_MPEG4_CORE_SCALABLE             10
  52. #define FF_PROFILE_MPEG4_ADVANCED_CODING           11
  53. #define FF_PROFILE_MPEG4_ADVANCED_CORE             12
  54. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
  55. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO             14
  56. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE           15

转载于:https://www.cnblogs.com/xihong2014/p/6707867.html

FFMPEG结构体分析:AVCodecContext(转)相关推荐

  1. FFMPEG结构体分析:AVCodecContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  2. FFMPEG结构体分析

    文章列表: FFMPEG结构体分析之AVCodecContext FFMPEG结构体分析之AVPacket FFMPEG结构体分析之AVCodec FFMPEG结构体分析之AVStream FFMPE ...

  3. FFMPEG结构体分析:AVPacket

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  4. FFMPEG结构体分析:AVStream

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  5. FFMPEG结构体分析:AVCodec

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  6. FFMPEG结构体分析:AVIOContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  7. FFMPEG结构体分析:AVFormatContext

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  8. FFMPEG结构体分析:AVFrame

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  9. FFMPEG结构体分析之AVCodecContext

    AVCodecContext,编码器上下文结构体,保存了视频(音频)编解码相关信息 AVCodecContext 结构体定义在文件ffmpeg/libavcodec/avcodec.h中 /*** m ...

最新文章

  1. ●洛谷P3168 [CQOI2015]任务查询系统
  2. spring系统学习:day4--Spring配置: 集合类型属性的注入
  3. 特征训练、预测一致性管理工具:开源项目Feast
  4. Spring MVC 源码分析
  5. nedc工况_东南DX3 EV续航升级 NEDC综合工况续航451公里
  6. 【matlab】找出数组中符合条件的数并赋值
  7. Linq在路上(序)
  8. java分布式dubbo_Dubbo剖析-搭建一个简单的分布式系统(1)
  9. linux ssh-keygen命令生成密钥 -t -C参数说明
  10. 用小学的试题测试你,换个脑袋吧~~~
  11. python基于Sen2Cor对哨兵影像进行大气校正
  12. 工业机器人编程语言c语言,工业机器人编程语言和编程方式
  13. 计算机里什么文件无法删除,电脑里面有哪些不能删除的文件?
  14. DeDeCMS二次开发教程之程序安装
  15. warning: array subscript has type ‘char‘
  16. splunk篇5-导出csv文件中文乱码
  17. 利用Navicat Premium导出数据库表结构信息至Excel
  18. 电梯门禁系统服务器一般在哪,电梯控制系统与门禁系统有区别吗
  19. Android build编译过程
  20. 基于Android+Node.js的智能语音报纸OCR识别阅读器

热门文章

  1. python计算组合数_Python实现的排列组合计算操作示例
  2. 【mysql】str_to_date()字符串转化为日期类型
  3. 【maven插件】flatten-maven-plugin : 处理版本占位符
  4. [linux]ps结果计算行数
  5. php cookie加密 类,PHP cookie加密类
  6. spring ResponseEntity
  7. java加快内存回收_java内存管理之垃圾回收及JVM调优
  8. mysql 字符串中取整_MySQL取整
  9. eclipse菜单字体乱码的解决
  10. 二十六、数据挖掘电力窃漏电用户自动识别