位置:
    AV系列结构体之AVCodecContext - 图1

    描述:主要扩展API的结构体

    1. typedef struct AVCodecContext {
    2. /**
    3. * information on struct for av_log
    4. * - set by avcodec_alloc_context3
    5. */
    6. const AVClass *av_class;
    7. int log_level_offset;
    8. enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
    9. const struct AVCodec *codec;
    10. #if FF_API_CODEC_NAME
    11. /**
    12. * @deprecated this field is not used for anything in libavcodec
    13. */
    14. attribute_deprecated
    15. char codec_name[32];
    16. #endif
    17. enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
    18. /**
    19. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
    20. * This is used to work around some encoder bugs.
    21. * A demuxer should set this to what is stored in the field used to identify the codec.
    22. * If there are multiple such fields in a container then the demuxer should choose the one
    23. * which maximizes the information about the used codec.
    24. * If the codec tag field in a container is larger than 32 bits then the demuxer should
    25. * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
    26. * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
    27. * first.
    28. * - encoding: Set by user, if not then the default based on codec_id will be used.
    29. * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
    30. */
    31. unsigned int codec_tag;
    32. #if FF_API_STREAM_CODEC_TAG
    33. /**
    34. * @deprecated this field is unused
    35. */
    36. attribute_deprecated
    37. unsigned int stream_codec_tag;
    38. #endif
    39. void *priv_data;
    40. /**
    41. * Private context used for internal data.
    42. *
    43. * Unlike priv_data, this is not codec-specific. It is used in general
    44. * libavcodec functions.
    45. */
    46. struct AVCodecInternal *internal;
    47. /**
    48. * Private data of the user, can be used to carry app specific stuff.
    49. * - encoding: Set by user.
    50. * - decoding: Set by user.
    51. */
    52. void *opaque;
    53. /**
    54. * the average bitrate
    55. * - encoding: Set by user; unused for constant quantizer encoding.
    56. * - decoding: Set by user, may be overwritten by libavcodec
    57. * if this info is available in the stream
    58. */
    59. int64_t bit_rate;
    60. /**
    61. * number of bits the bitstream is allowed to diverge from the reference.
    62. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
    63. * - encoding: Set by user; unused for constant quantizer encoding.
    64. * - decoding: unused
    65. */
    66. int bit_rate_tolerance;
    67. /**
    68. * Global quality for codecs which cannot change it per frame.
    69. * This should be proportional to MPEG-1/2/4 qscale.
    70. * - encoding: Set by user.
    71. * - decoding: unused
    72. */
    73. int global_quality;
    74. /**
    75. * - encoding: Set by user.
    76. * - decoding: unused
    77. */
    78. int compression_level;
    79. #define FF_COMPRESSION_DEFAULT -1
    80. /**
    81. * AV_CODEC_FLAG_*.
    82. * - encoding: Set by user.
    83. * - decoding: Set by user.
    84. */
    85. int flags;
    86. /**
    87. * AV_CODEC_FLAG2_*
    88. * - encoding: Set by user.
    89. * - decoding: Set by user.
    90. */
    91. int flags2;
    92. /**
    93. * some codecs need / can use extradata like Huffman tables.
    94. * MJPEG: Huffman tables
    95. * rv10: additional flags
    96. * MPEG-4: global headers (they can be in the bitstream or here)
    97. * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
    98. * than extradata_size to avoid problems if it is read with the bitstream reader.
    99. * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
    100. * - encoding: Set/allocated/freed by libavcodec.
    101. * - decoding: Set/allocated/freed by user.
    102. */
    103. uint8_t *extradata;
    104. int extradata_size;
    105. /**
    106. * This is the fundamental unit of time (in seconds) in terms
    107. * of which frame timestamps are represented. For fixed-fps content,
    108. * timebase should be 1/framerate and timestamp increments should be
    109. * identically 1.
    110. * This often, but not always is the inverse of the frame rate or field rate
    111. * for video. 1/time_base is not the average frame rate if the frame rate is not
    112. * constant.
    113. *
    114. * Like containers, elementary streams also can store timestamps, 1/time_base
    115. * is the unit in which these timestamps are specified.
    116. * As example of such codec time base see ISO/IEC 14496-2:2001(E)
    117. * vop_time_increment_resolution and fixed_vop_rate
    118. * (fixed_vop_rate == 0 implies that it is different from the framerate)
    119. *
    120. * - encoding: MUST be set by user.
    121. * - decoding: the use of this field for decoding is deprecated.
    122. * Use framerate instead.
    123. */
    124. AVRational time_base;
    125. /**
    126. * For some codecs, the time base is closer to the field rate than the frame rate.
    127. * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
    128. * if no telecine is used ...
    129. *
    130. * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
    131. */
    132. int ticks_per_frame;
    133. /**
    134. * Codec delay.
    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 field is unused (see initial_padding).
    147. *
    148. * For decoding, this is the number of samples the decoder needs to
    149. * output before the decoder's output is valid. When seeking, you should
    150. * start decoding this many samples prior to your desired seek point.
    151. *
    152. * - encoding: Set by libavcodec.
    153. * - decoding: Set by libavcodec.
    154. */
    155. int delay;
    156. /* video only */
    157. /**
    158. * picture width / height.
    159. *
    160. * @note Those fields may not match the values of the last
    161. * AVFrame output by avcodec_decode_video2 due frame
    162. * reordering.
    163. *
    164. * - encoding: MUST be set by user.
    165. * - decoding: May be set by the user before opening the decoder if known e.g.
    166. * from the container. Some decoders will require the dimensions
    167. * to be set by the caller. During decoding, the decoder may
    168. * overwrite those values as required while parsing the data.
    169. */
    170. int width, height;
    171. /**
    172. * Bitstream width / height, may be different from width/height e.g. when
    173. * the decoded frame is cropped before being output or lowres is enabled.
    174. *
    175. * @note Those field may not match the value of the last
    176. * AVFrame output by avcodec_receive_frame() due frame
    177. * reordering.
    178. *
    179. * - encoding: unused
    180. * - decoding: May be set by the user before opening the decoder if known
    181. * e.g. from the container. During decoding, the decoder may
    182. * overwrite those values as required while parsing the data.
    183. */
    184. int coded_width, coded_height;
    185. #if FF_API_ASPECT_EXTENDED
    186. #define FF_ASPECT_EXTENDED 15
    187. #endif
    188. /**
    189. * the number of pictures in a group of pictures, or 0 for intra_only
    190. * - encoding: Set by user.
    191. * - decoding: unused
    192. */
    193. int gop_size;
    194. /**
    195. * Pixel format, see AV_PIX_FMT_xxx.
    196. * May be set by the demuxer if known from headers.
    197. * May be overridden by the decoder if it knows better.
    198. *
    199. * @note This field may not match the value of the last
    200. * AVFrame output by avcodec_receive_frame() due frame
    201. * reordering.
    202. *
    203. * - encoding: Set by user.
    204. * - decoding: Set by user if known, overridden by libavcodec while
    205. * parsing the data.
    206. */
    207. enum AVPixelFormat pix_fmt;
    208. #if FF_API_MOTION_EST
    209. /**
    210. * This option does nothing
    211. * @deprecated use codec private options instead
    212. */
    213. attribute_deprecated int me_method;
    214. #endif
    215. /**
    216. * If non NULL, 'draw_horiz_band' is called by the libavcodec
    217. * decoder to draw a horizontal band. It improves cache usage. Not
    218. * all codecs can do that. You must check the codec capabilities
    219. * beforehand.
    220. * When multithreading is used, it may be called from multiple threads
    221. * at the same time; threads might draw different parts of the same AVFrame,
    222. * or multiple AVFrames, and there is no guarantee that slices will be drawn
    223. * in order.
    224. * The function is also used by hardware acceleration APIs.
    225. * It is called at least once during frame decoding to pass
    226. * the data needed for hardware render.
    227. * In that mode instead of pixel data, AVFrame points to
    228. * a structure specific to the acceleration API. The application
    229. * reads the structure and can change some fields to indicate progress
    230. * or mark state.
    231. * - encoding: unused
    232. * - decoding: Set by user.
    233. * @param height the height of the slice
    234. * @param y the y position of the slice
    235. * @param type 1->top field, 2->bottom field, 3->frame
    236. * @param offset offset into the AVFrame.data from which the slice should be read
    237. */
    238. void (*draw_horiz_band)(struct AVCodecContext *s,
    239. const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
    240. int y, int type, int height);
    241. /**
    242. * callback to negotiate the pixelFormat
    243. * @param fmt is the list of formats which are supported by the codec,
    244. * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
    245. * The first is always the native one.
    246. * @note The callback may be called again immediately if initialization for
    247. * the selected (hardware-accelerated) pixel format failed.
    248. * @warning Behavior is undefined if the callback returns a value not
    249. * in the fmt list of formats.
    250. * @return the chosen format
    251. * - encoding: unused
    252. * - decoding: Set by user, if not set the native format will be chosen.
    253. */
    254. enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
    255. /**
    256. * maximum number of B-frames between non-B-frames
    257. * Note: The output will be delayed by max_b_frames+1 relative to the input.
    258. * - encoding: Set by user.
    259. * - decoding: unused
    260. */
    261. int max_b_frames;
    262. /**
    263. * qscale factor between IP and B-frames
    264. * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
    265. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
    266. * - encoding: Set by user.
    267. * - decoding: unused
    268. */
    269. float b_quant_factor;
    270. #if FF_API_RC_STRATEGY
    271. /** @deprecated use codec private option instead */
    272. attribute_deprecated int rc_strategy;
    273. #define FF_RC_STRATEGY_XVID 1
    274. #endif
    275. #if FF_API_PRIVATE_OPT
    276. /** @deprecated use encoder private options instead */
    277. attribute_deprecated
    278. int b_frame_strategy;
    279. #endif
    280. /**
    281. * qscale offset between IP and B-frames
    282. * - encoding: Set by user.
    283. * - decoding: unused
    284. */
    285. float b_quant_offset;
    286. /**
    287. * Size of the frame reordering buffer in the decoder.
    288. * For MPEG-2 it is 1 IPB or 0 low delay IP.
    289. * - encoding: Set by libavcodec.
    290. * - decoding: Set by libavcodec.
    291. */
    292. int has_b_frames;
    293. #if FF_API_PRIVATE_OPT
    294. /** @deprecated use encoder private options instead */
    295. attribute_deprecated
    296. int mpeg_quant;
    297. #endif
    298. /**
    299. * qscale factor between P- and I-frames
    300. * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
    301. * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
    302. * - encoding: Set by user.
    303. * - decoding: unused
    304. */
    305. float i_quant_factor;
    306. /**
    307. * qscale offset between P and I-frames
    308. * - encoding: Set by user.
    309. * - decoding: unused
    310. */
    311. float i_quant_offset;
    312. /**
    313. * luminance masking (0-> disabled)
    314. * - encoding: Set by user.
    315. * - decoding: unused
    316. */
    317. float lumi_masking;
    318. /**
    319. * temporary complexity masking (0-> disabled)
    320. * - encoding: Set by user.
    321. * - decoding: unused
    322. */
    323. float temporal_cplx_masking;
    324. /**
    325. * spatial complexity masking (0-> disabled)
    326. * - encoding: Set by user.
    327. * - decoding: unused
    328. */
    329. float spatial_cplx_masking;
    330. /**
    331. * p block masking (0-> disabled)
    332. * - encoding: Set by user.
    333. * - decoding: unused
    334. */
    335. float p_masking;
    336. /**
    337. * darkness masking (0-> disabled)
    338. * - encoding: Set by user.
    339. * - decoding: unused
    340. */
    341. float dark_masking;
    342. /**
    343. * slice count
    344. * - encoding: Set by libavcodec.
    345. * - decoding: Set by user (or 0).
    346. */
    347. int slice_count;
    348. #if FF_API_PRIVATE_OPT
    349. /** @deprecated use encoder private options instead */
    350. attribute_deprecated
    351. int prediction_method;
    352. #define FF_PRED_LEFT 0
    353. #define FF_PRED_PLANE 1
    354. #define FF_PRED_MEDIAN 2
    355. #endif
    356. /**
    357. * slice offsets in the frame in bytes
    358. * - encoding: Set/allocated by libavcodec.
    359. * - decoding: Set/allocated by user (or NULL).
    360. */
    361. int *slice_offset;
    362. /**
    363. * sample aspect ratio (0 if unknown)
    364. * That is the width of a pixel divided by the height of the pixel.
    365. * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
    366. * - encoding: Set by user.
    367. * - decoding: Set by libavcodec.
    368. */
    369. AVRational sample_aspect_ratio;
    370. /**
    371. * motion estimation comparison function
    372. * - encoding: Set by user.
    373. * - decoding: unused
    374. */
    375. int me_cmp;
    376. /**
    377. * subpixel motion estimation comparison function
    378. * - encoding: Set by user.
    379. * - decoding: unused
    380. */
    381. int me_sub_cmp;
    382. /**
    383. * macroblock comparison function (not supported yet)
    384. * - encoding: Set by user.
    385. * - decoding: unused
    386. */
    387. int mb_cmp;
    388. /**
    389. * interlaced DCT comparison function
    390. * - encoding: Set by user.
    391. * - decoding: unused
    392. */
    393. int ildct_cmp;
    394. #define FF_CMP_SAD 0
    395. #define FF_CMP_SSE 1
    396. #define FF_CMP_SATD 2
    397. #define FF_CMP_DCT 3
    398. #define FF_CMP_PSNR 4
    399. #define FF_CMP_BIT 5
    400. #define FF_CMP_RD 6
    401. #define FF_CMP_ZERO 7
    402. #define FF_CMP_VSAD 8
    403. #define FF_CMP_VSSE 9
    404. #define FF_CMP_NSSE 10
    405. #define FF_CMP_W53 11
    406. #define FF_CMP_W97 12
    407. #define FF_CMP_DCTMAX 13
    408. #define FF_CMP_DCT264 14
    409. #define FF_CMP_CHROMA 256
    410. /**
    411. * ME diamond size & shape
    412. * - encoding: Set by user.
    413. * - decoding: unused
    414. */
    415. int dia_size;
    416. /**
    417. * amount of previous MV predictors (2a+1 x 2a+1 square)
    418. * - encoding: Set by user.
    419. * - decoding: unused
    420. */
    421. int last_predictor_count;
    422. #if FF_API_PRIVATE_OPT
    423. /** @deprecated use encoder private options instead */
    424. attribute_deprecated
    425. int pre_me;
    426. #endif
    427. /**
    428. * motion estimation prepass comparison function
    429. * - encoding: Set by user.
    430. * - decoding: unused
    431. */
    432. int me_pre_cmp;
    433. /**
    434. * ME prepass diamond size & shape
    435. * - encoding: Set by user.
    436. * - decoding: unused
    437. */
    438. int pre_dia_size;
    439. /**
    440. * subpel ME quality
    441. * - encoding: Set by user.
    442. * - decoding: unused
    443. */
    444. int me_subpel_quality;
    445. #if FF_API_AFD
    446. /**
    447. * DTG active format information (additional aspect ratio
    448. * information only used in DVB MPEG-2 transport streams)
    449. * 0 if not set.
    450. *
    451. * - encoding: unused
    452. * - decoding: Set by decoder.
    453. * @deprecated Deprecated in favor of AVSideData
    454. */
    455. attribute_deprecated int dtg_active_format;
    456. #define FF_DTG_AFD_SAME 8
    457. #define FF_DTG_AFD_4_3 9
    458. #define FF_DTG_AFD_16_9 10
    459. #define FF_DTG_AFD_14_9 11
    460. #define FF_DTG_AFD_4_3_SP_14_9 13
    461. #define FF_DTG_AFD_16_9_SP_14_9 14
    462. #define FF_DTG_AFD_SP_4_3 15
    463. #endif /* FF_API_AFD */
    464. /**
    465. * maximum motion estimation search range in subpel units
    466. * If 0 then no limit.
    467. *
    468. * - encoding: Set by user.
    469. * - decoding: unused
    470. */
    471. int me_range;
    472. #if FF_API_QUANT_BIAS
    473. /**
    474. * @deprecated use encoder private option instead
    475. */
    476. attribute_deprecated int intra_quant_bias;
    477. #define FF_DEFAULT_QUANT_BIAS 999999
    478. /**
    479. * @deprecated use encoder private option instead
    480. */
    481. attribute_deprecated int inter_quant_bias;
    482. #endif
    483. /**
    484. * slice flags
    485. * - encoding: unused
    486. * - decoding: Set by user.
    487. */
    488. int slice_flags;
    489. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
    490. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
    491. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
    492. #if FF_API_XVMC
    493. /**
    494. * XVideo Motion Acceleration
    495. * - encoding: forbidden
    496. * - decoding: set by decoder
    497. * @deprecated XvMC doesn't need it anymore.
    498. */
    499. attribute_deprecated int xvmc_acceleration;
    500. #endif /* FF_API_XVMC */
    501. /**
    502. * macroblock decision mode
    503. * - encoding: Set by user.
    504. * - decoding: unused
    505. */
    506. int mb_decision;
    507. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
    508. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
    509. #define FF_MB_DECISION_RD 2 ///< rate distortion
    510. /**
    511. * custom intra quantization matrix
    512. * - encoding: Set by user, can be NULL.
    513. * - decoding: Set by libavcodec.
    514. */
    515. uint16_t *intra_matrix;
    516. /**
    517. * custom inter quantization matrix
    518. * - encoding: Set by user, can be NULL.
    519. * - decoding: Set by libavcodec.
    520. */
    521. uint16_t *inter_matrix;
    522. #if FF_API_PRIVATE_OPT
    523. /** @deprecated use encoder private options instead */
    524. attribute_deprecated
    525. int scenechange_threshold;
    526. /** @deprecated use encoder private options instead */
    527. attribute_deprecated
    528. int noise_reduction;
    529. #endif
    530. #if FF_API_MPV_OPT
    531. /**
    532. * @deprecated this field is unused
    533. */
    534. attribute_deprecated
    535. int me_threshold;
    536. /**
    537. * @deprecated this field is unused
    538. */
    539. attribute_deprecated
    540. int mb_threshold;
    541. #endif
    542. /**
    543. * precision of the intra DC coefficient - 8
    544. * - encoding: Set by user.
    545. * - decoding: Set by libavcodec
    546. */
    547. int intra_dc_precision;
    548. /**
    549. * Number of macroblock rows at the top which are skipped.
    550. * - encoding: unused
    551. * - decoding: Set by user.
    552. */
    553. int skip_top;
    554. /**
    555. * Number of macroblock rows at the bottom which are skipped.
    556. * - encoding: unused
    557. * - decoding: Set by user.
    558. */
    559. int skip_bottom;
    560. #if FF_API_MPV_OPT
    561. /**
    562. * @deprecated use encoder private options instead
    563. */
    564. attribute_deprecated
    565. float border_masking;
    566. #endif
    567. /**
    568. * minimum MB Lagrange multiplier
    569. * - encoding: Set by user.
    570. * - decoding: unused
    571. */
    572. int mb_lmin;
    573. /**
    574. * maximum MB Lagrange multiplier
    575. * - encoding: Set by user.
    576. * - decoding: unused
    577. */
    578. int mb_lmax;
    579. #if FF_API_PRIVATE_OPT
    580. /**
    581. * @deprecated use encoder private options instead
    582. */
    583. attribute_deprecated
    584. int me_penalty_compensation;
    585. #endif
    586. /**
    587. * - encoding: Set by user.
    588. * - decoding: unused
    589. */
    590. int bidir_refine;
    591. #if FF_API_PRIVATE_OPT
    592. /** @deprecated use encoder private options instead */
    593. attribute_deprecated
    594. int brd_scale;
    595. #endif
    596. /**
    597. * minimum GOP size
    598. * - encoding: Set by user.
    599. * - decoding: unused
    600. */
    601. int keyint_min;
    602. /**
    603. * number of reference frames
    604. * - encoding: Set by user.
    605. * - decoding: Set by lavc.
    606. */
    607. int refs;
    608. #if FF_API_PRIVATE_OPT
    609. /** @deprecated use encoder private options instead */
    610. attribute_deprecated
    611. int chromaoffset;
    612. #endif
    613. #if FF_API_UNUSED_MEMBERS
    614. /**
    615. * Multiplied by qscale for each frame and added to scene_change_score.
    616. * - encoding: Set by user.
    617. * - decoding: unused
    618. */
    619. attribute_deprecated int scenechange_factor;
    620. #endif
    621. /**
    622. * Note: Value depends upon the compare function used for fullpel ME.
    623. * - encoding: Set by user.
    624. * - decoding: unused
    625. */
    626. int mv0_threshold;
    627. #if FF_API_PRIVATE_OPT
    628. /** @deprecated use encoder private options instead */
    629. attribute_deprecated
    630. int b_sensitivity;
    631. #endif
    632. /**
    633. * Chromaticity coordinates of the source primaries.
    634. * - encoding: Set by user
    635. * - decoding: Set by libavcodec
    636. */
    637. enum AVColorPrimaries color_primaries;
    638. /**
    639. * Color Transfer Characteristic.
    640. * - encoding: Set by user
    641. * - decoding: Set by libavcodec
    642. */
    643. enum AVColorTransferCharacteristic color_trc;
    644. /**
    645. * YUV colorspace type.
    646. * - encoding: Set by user
    647. * - decoding: Set by libavcodec
    648. */
    649. enum AVColorSpace colorspace;
    650. /**
    651. * MPEG vs JPEG YUV range.
    652. * - encoding: Set by user
    653. * - decoding: Set by libavcodec
    654. */
    655. enum AVColorRange color_range;
    656. /**
    657. * This defines the location of chroma samples.
    658. * - encoding: Set by user
    659. * - decoding: Set by libavcodec
    660. */
    661. enum AVChromaLocation chroma_sample_location;
    662. /**
    663. * Number of slices.
    664. * Indicates number of picture subdivisions. Used for parallelized
    665. * decoding.
    666. * - encoding: Set by user
    667. * - decoding: unused
    668. */
    669. int slices;
    670. /** Field order
    671. * - encoding: set by libavcodec
    672. * - decoding: Set by user.
    673. */
    674. enum AVFieldOrder field_order;
    675. /* audio only */
    676. int sample_rate; ///< samples per second
    677. int channels; ///< number of audio channels
    678. /**
    679. * audio sample format
    680. * - encoding: Set by user.
    681. * - decoding: Set by libavcodec.
    682. */
    683. enum AVSampleFormat sample_fmt; ///< sample format
    684. /* The following data should not be initialized. */
    685. /**
    686. * Number of samples per channel in an audio frame.
    687. *
    688. * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
    689. * except the last must contain exactly frame_size samples per channel.
    690. * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
    691. * frame size is not restricted.
    692. * - decoding: may be set by some decoders to indicate constant frame size
    693. */
    694. int frame_size;
    695. /**
    696. * Frame counter, set by libavcodec.
    697. *
    698. * - decoding: total number of frames returned from the decoder so far.
    699. * - encoding: total number of frames passed to the encoder so far.
    700. *
    701. * @note the counter is not incremented if encoding/decoding resulted in
    702. * an error.
    703. */
    704. int frame_number;
    705. /**
    706. * number of bytes per packet if constant and known or 0
    707. * Used by some WAV based audio codecs.
    708. */
    709. int block_align;
    710. /**
    711. * Audio cutoff bandwidth (0 means "automatic")
    712. * - encoding: Set by user.
    713. * - decoding: unused
    714. */
    715. int cutoff;
    716. /**
    717. * Audio channel layout.
    718. * - encoding: set by user.
    719. * - decoding: set by user, may be overwritten by libavcodec.
    720. */
    721. uint64_t channel_layout;
    722. /**
    723. * Request decoder to use this channel layout if it can (0 for default)
    724. * - encoding: unused
    725. * - decoding: Set by user.
    726. */
    727. uint64_t request_channel_layout;
    728. /**
    729. * Type of service that the audio stream conveys.
    730. * - encoding: Set by user.
    731. * - decoding: Set by libavcodec.
    732. */
    733. enum AVAudioServiceType audio_service_type;
    734. /**
    735. * desired sample format
    736. * - encoding: Not used.
    737. * - decoding: Set by user.
    738. * Decoder will decode to this format if it can.
    739. */
    740. enum AVSampleFormat request_sample_fmt;
    741. /**
    742. * This callback is called at the beginning of each frame to get data
    743. * buffer(s) for it. There may be one contiguous buffer for all the data or
    744. * there may be a buffer per each data plane or anything in between. What
    745. * this means is, you may set however many entries in buf[] you feel necessary.
    746. * Each buffer must be reference-counted using the AVBuffer API (see description
    747. * of buf[] below).
    748. *
    749. * The following fields will be set in the frame before this callback is
    750. * called:
    751. * - format
    752. * - width, height (video only)
    753. * - sample_rate, channel_layout, nb_samples (audio only)
    754. * Their values may differ from the corresponding values in
    755. * AVCodecContext. This callback must use the frame values, not the codec
    756. * context values, to calculate the required buffer size.
    757. *
    758. * This callback must fill the following fields in the frame:
    759. * - data[]
    760. * - linesize[]
    761. * - extended_data:
    762. * * if the data is planar audio with more than 8 channels, then this
    763. * callback must allocate and fill extended_data to contain all pointers
    764. * to all data planes. data[] must hold as many pointers as it can.
    765. * extended_data must be allocated with av_malloc() and will be freed in
    766. * av_frame_unref().
    767. * * otherwise extended_data must point to data
    768. * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
    769. * the frame's data and extended_data pointers must be contained in these. That
    770. * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
    771. * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
    772. * and av_buffer_ref().
    773. * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
    774. * this callback and filled with the extra buffers if there are more
    775. * buffers than buf[] can hold. extended_buf will be freed in
    776. * av_frame_unref().
    777. *
    778. * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
    779. * avcodec_default_get_buffer2() instead of providing buffers allocated by
    780. * some other means.
    781. *
    782. * Each data plane must be aligned to the maximum required by the target
    783. * CPU.
    784. *
    785. * @see avcodec_default_get_buffer2()
    786. *
    787. * Video:
    788. *
    789. * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
    790. * (read and/or written to if it is writable) later by libavcodec.
    791. *
    792. * avcodec_align_dimensions2() should be used to find the required width and
    793. * height, as they normally need to be rounded up to the next multiple of 16.
    794. *
    795. * Some decoders do not support linesizes changing between frames.
    796. *
    797. * If frame multithreading is used and thread_safe_callbacks is set,
    798. * this callback may be called from a different thread, but not from more
    799. * than one at once. Does not need to be reentrant.
    800. *
    801. * @see avcodec_align_dimensions2()
    802. *
    803. * Audio:
    804. *
    805. * Decoders request a buffer of a particular size by setting
    806. * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
    807. * however, utilize only part of the buffer by setting AVFrame.nb_samples
    808. * to a smaller value in the output frame.
    809. *
    810. * As a convenience, av_samples_get_buffer_size() and
    811. * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
    812. * functions to find the required data size and to fill data pointers and
    813. * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
    814. * since all planes must be the same size.
    815. *
    816. * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
    817. *
    818. * - encoding: unused
    819. * - decoding: Set by libavcodec, user can override.
    820. */
    821. int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
    822. /**
    823. * If non-zero, the decoded audio and video frames returned from
    824. * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
    825. * and are valid indefinitely. The caller must free them with
    826. * av_frame_unref() when they are not needed anymore.
    827. * Otherwise, the decoded frames must not be freed by the caller and are
    828. * only valid until the next decode call.
    829. *
    830. * This is always automatically enabled if avcodec_receive_frame() is used.
    831. *
    832. * - encoding: unused
    833. * - decoding: set by the caller before avcodec_open2().
    834. */
    835. int refcounted_frames;
    836. /* - encoding parameters */
    837. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
    838. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
    839. /**
    840. * minimum quantizer
    841. * - encoding: Set by user.
    842. * - decoding: unused
    843. */
    844. int qmin;
    845. /**
    846. * maximum quantizer
    847. * - encoding: Set by user.
    848. * - decoding: unused
    849. */
    850. int qmax;
    851. /**
    852. * maximum quantizer difference between frames
    853. * - encoding: Set by user.
    854. * - decoding: unused
    855. */
    856. int max_qdiff;
    857. #if FF_API_MPV_OPT
    858. /**
    859. * @deprecated use encoder private options instead
    860. */
    861. attribute_deprecated
    862. float rc_qsquish;
    863. attribute_deprecated
    864. float rc_qmod_amp;
    865. attribute_deprecated
    866. int rc_qmod_freq;
    867. #endif
    868. /**
    869. * decoder bitstream buffer size
    870. * - encoding: Set by user.
    871. * - decoding: unused
    872. */
    873. int rc_buffer_size;
    874. /**
    875. * ratecontrol override, see RcOverride
    876. * - encoding: Allocated/set/freed by user.
    877. * - decoding: unused
    878. */
    879. int rc_override_count;
    880. RcOverride *rc_override;
    881. #if FF_API_MPV_OPT
    882. /**
    883. * @deprecated use encoder private options instead
    884. */
    885. attribute_deprecated
    886. const char *rc_eq;
    887. #endif
    888. /**
    889. * maximum bitrate
    890. * - encoding: Set by user.
    891. * - decoding: Set by user, may be overwritten by libavcodec.
    892. */
    893. int64_t rc_max_rate;
    894. /**
    895. * minimum bitrate
    896. * - encoding: Set by user.
    897. * - decoding: unused
    898. */
    899. int64_t rc_min_rate;
    900. #if FF_API_MPV_OPT
    901. /**
    902. * @deprecated use encoder private options instead
    903. */
    904. attribute_deprecated
    905. float rc_buffer_aggressivity;
    906. attribute_deprecated
    907. float rc_initial_cplx;
    908. #endif
    909. /**
    910. * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
    911. * - encoding: Set by user.
    912. * - decoding: unused.
    913. */
    914. float rc_max_available_vbv_use;
    915. /**
    916. * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
    917. * - encoding: Set by user.
    918. * - decoding: unused.
    919. */
    920. float rc_min_vbv_overflow_use;
    921. /**
    922. * Number of bits which should be loaded into the rc buffer before decoding starts.
    923. * - encoding: Set by user.
    924. * - decoding: unused
    925. */
    926. int rc_initial_buffer_occupancy;
    927. #if FF_API_CODER_TYPE
    928. #define FF_CODER_TYPE_VLC 0
    929. #define FF_CODER_TYPE_AC 1
    930. #define FF_CODER_TYPE_RAW 2
    931. #define FF_CODER_TYPE_RLE 3
    932. #if FF_API_UNUSED_MEMBERS
    933. #define FF_CODER_TYPE_DEFLATE 4
    934. #endif /* FF_API_UNUSED_MEMBERS */
    935. /**
    936. * @deprecated use encoder private options instead
    937. */
    938. attribute_deprecated
    939. int coder_type;
    940. #endif /* FF_API_CODER_TYPE */
    941. #if FF_API_PRIVATE_OPT
    942. /** @deprecated use encoder private options instead */
    943. attribute_deprecated
    944. int context_model;
    945. #endif
    946. #if FF_API_MPV_OPT
    947. /**
    948. * @deprecated use encoder private options instead
    949. */
    950. attribute_deprecated
    951. int lmin;
    952. /**
    953. * @deprecated use encoder private options instead
    954. */
    955. attribute_deprecated
    956. int lmax;
    957. #endif
    958. #if FF_API_PRIVATE_OPT
    959. /** @deprecated use encoder private options instead */
    960. attribute_deprecated
    961. int frame_skip_threshold;
    962. /** @deprecated use encoder private options instead */
    963. attribute_deprecated
    964. int frame_skip_factor;
    965. /** @deprecated use encoder private options instead */
    966. attribute_deprecated
    967. int frame_skip_exp;
    968. /** @deprecated use encoder private options instead */
    969. attribute_deprecated
    970. int frame_skip_cmp;
    971. #endif /* FF_API_PRIVATE_OPT */
    972. /**
    973. * trellis RD quantization
    974. * - encoding: Set by user.
    975. * - decoding: unused
    976. */
    977. int trellis;
    978. #if FF_API_PRIVATE_OPT
    979. /** @deprecated use encoder private options instead */
    980. attribute_deprecated
    981. int min_prediction_order;
    982. /** @deprecated use encoder private options instead */
    983. attribute_deprecated
    984. int max_prediction_order;
    985. /** @deprecated use encoder private options instead */
    986. attribute_deprecated
    987. int64_t timecode_frame_start;
    988. #endif
    989. #if FF_API_RTP_CALLBACK
    990. /**
    991. * @deprecated unused
    992. */
    993. /* The RTP callback: This function is called */
    994. /* every time the encoder has a packet to send. */
    995. /* It depends on the encoder if the data starts */
    996. /* with a Start Code (it should). H.263 does. */
    997. /* mb_nb contains the number of macroblocks */
    998. /* encoded in the RTP payload. */
    999. attribute_deprecated
    1000. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
    1001. #endif
    1002. #if FF_API_PRIVATE_OPT
    1003. /** @deprecated use encoder private options instead */
    1004. attribute_deprecated
    1005. int rtp_payload_size; /* The size of the RTP payload: the coder will */
    1006. /* do its best to deliver a chunk with size */
    1007. /* below rtp_payload_size, the chunk will start */
    1008. /* with a start code on some codecs like H.263. */
    1009. /* This doesn't take account of any particular */
    1010. /* headers inside the transmitted RTP payload. */
    1011. #endif
    1012. #if FF_API_STAT_BITS
    1013. /* statistics, used for 2-pass encoding */
    1014. attribute_deprecated
    1015. int mv_bits;
    1016. attribute_deprecated
    1017. int header_bits;
    1018. attribute_deprecated
    1019. int i_tex_bits;
    1020. attribute_deprecated
    1021. int p_tex_bits;
    1022. attribute_deprecated
    1023. int i_count;
    1024. attribute_deprecated
    1025. int p_count;
    1026. attribute_deprecated
    1027. int skip_count;
    1028. attribute_deprecated
    1029. int misc_bits;
    1030. /** @deprecated this field is unused */
    1031. attribute_deprecated
    1032. int frame_bits;
    1033. #endif
    1034. /**
    1035. * pass1 encoding statistics output buffer
    1036. * - encoding: Set by libavcodec.
    1037. * - decoding: unused
    1038. */
    1039. char *stats_out;
    1040. /**
    1041. * pass2 encoding statistics input buffer
    1042. * Concatenated stuff from stats_out of pass1 should be placed here.
    1043. * - encoding: Allocated/set/freed by user.
    1044. * - decoding: unused
    1045. */
    1046. char *stats_in;
    1047. /**
    1048. * Work around bugs in encoders which sometimes cannot be detected automatically.
    1049. * - encoding: Set by user
    1050. * - decoding: Set by user
    1051. */
    1052. int workaround_bugs;
    1053. #define FF_BUG_AUTODETECT 1 ///< autodetection
    1054. #if FF_API_OLD_MSMPEG4
    1055. #define FF_BUG_OLD_MSMPEG4 2
    1056. #endif
    1057. #define FF_BUG_XVID_ILACE 4
    1058. #define FF_BUG_UMP4 8
    1059. #define FF_BUG_NO_PADDING 16
    1060. #define FF_BUG_AMV 32
    1061. #if FF_API_AC_VLC
    1062. #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
    1063. #endif
    1064. #define FF_BUG_QPEL_CHROMA 64
    1065. #define FF_BUG_STD_QPEL 128
    1066. #define FF_BUG_QPEL_CHROMA2 256
    1067. #define FF_BUG_DIRECT_BLOCKSIZE 512
    1068. #define FF_BUG_EDGE 1024
    1069. #define FF_BUG_HPEL_CHROMA 2048
    1070. #define FF_BUG_DC_CLIP 4096
    1071. #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
    1072. #define FF_BUG_TRUNCATED 16384
    1073. /**
    1074. * strictly follow the standard (MPEG-4, ...).
    1075. * - encoding: Set by user.
    1076. * - decoding: Set by user.
    1077. * Setting this to STRICT or higher means the encoder and decoder will
    1078. * generally do stupid things, whereas setting it to unofficial or lower
    1079. * will mean the encoder might produce output that is not supported by all
    1080. * spec-compliant decoders. Decoders don't differentiate between normal,
    1081. * unofficial and experimental (that is, they always try to decode things
    1082. * when they can) unless they are explicitly asked to behave stupidly
    1083. * (=strictly conform to the specs)
    1084. */
    1085. int strict_std_compliance;
    1086. #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
    1087. #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
    1088. #define FF_COMPLIANCE_NORMAL 0
    1089. #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
    1090. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
    1091. /**
    1092. * error concealment flags
    1093. * - encoding: unused
    1094. * - decoding: Set by user.
    1095. */
    1096. int error_concealment;
    1097. #define FF_EC_GUESS_MVS 1
    1098. #define FF_EC_DEBLOCK 2
    1099. #define FF_EC_FAVOR_INTER 256
    1100. /**
    1101. * debug
    1102. * - encoding: Set by user.
    1103. * - decoding: Set by user.
    1104. */
    1105. int debug;
    1106. #define FF_DEBUG_PICT_INFO 1
    1107. #define FF_DEBUG_RC 2
    1108. #define FF_DEBUG_BITSTREAM 4
    1109. #define FF_DEBUG_MB_TYPE 8
    1110. #define FF_DEBUG_QP 16
    1111. #if FF_API_DEBUG_MV
    1112. /**
    1113. * @deprecated this option does nothing
    1114. */
    1115. #define FF_DEBUG_MV 32
    1116. #endif
    1117. #define FF_DEBUG_DCT_COEFF 0x00000040
    1118. #define FF_DEBUG_SKIP 0x00000080
    1119. #define FF_DEBUG_STARTCODE 0x00000100
    1120. #if FF_API_UNUSED_MEMBERS
    1121. #define FF_DEBUG_PTS 0x00000200
    1122. #endif /* FF_API_UNUSED_MEMBERS */
    1123. #define FF_DEBUG_ER 0x00000400
    1124. #define FF_DEBUG_MMCO 0x00000800
    1125. #define FF_DEBUG_BUGS 0x00001000
    1126. #if FF_API_DEBUG_MV
    1127. #define FF_DEBUG_VIS_QP 0x00002000 ///< only access through AVOptions from outside libavcodec
    1128. #define FF_DEBUG_VIS_MB_TYPE 0x00004000 ///< only access through AVOptions from outside libavcodec
    1129. #endif
    1130. #define FF_DEBUG_BUFFERS 0x00008000
    1131. #define FF_DEBUG_THREADS 0x00010000
    1132. #define FF_DEBUG_GREEN_MD 0x00800000
    1133. #define FF_DEBUG_NOMC 0x01000000
    1134. #if FF_API_DEBUG_MV
    1135. /**
    1136. * debug
    1137. * Code outside libavcodec should access this field using AVOptions
    1138. * - encoding: Set by user.
    1139. * - decoding: Set by user.
    1140. */
    1141. int debug_mv;
    1142. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames
    1143. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames
    1144. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
    1145. #endif
    1146. /**
    1147. * Error recognition; may misdetect some more or less valid parts as errors.
    1148. * - encoding: unused
    1149. * - decoding: Set by user.
    1150. */
    1151. int err_recognition;
    1152. /**
    1153. * Verify checksums embedded in the bitstream (could be of either encoded or
    1154. * decoded data, depending on the codec) and print an error message on mismatch.
    1155. * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
    1156. * decoder returning an error.
    1157. */
    1158. #define AV_EF_CRCCHECK (1<<0)
    1159. #define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations
    1160. #define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length
    1161. #define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection
    1162. #define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue
    1163. #define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
    1164. #define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors
    1165. #define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error
    1166. /**
    1167. * opaque 64-bit number (generally a PTS) that will be reordered and
    1168. * output in AVFrame.reordered_opaque
    1169. * - encoding: unused
    1170. * - decoding: Set by user.
    1171. */
    1172. int64_t reordered_opaque;
    1173. /**
    1174. * Hardware accelerator in use
    1175. * - encoding: unused.
    1176. * - decoding: Set by libavcodec
    1177. */
    1178. struct AVHWAccel *hwaccel;
    1179. /**
    1180. * Hardware accelerator context.
    1181. * For some hardware accelerators, a global context needs to be
    1182. * provided by the user. In that case, this holds display-dependent
    1183. * data FFmpeg cannot instantiate itself. Please refer to the
    1184. * FFmpeg HW accelerator documentation to know how to fill this
    1185. * is. e.g. for VA API, this is a struct vaapi_context.
    1186. * - encoding: unused
    1187. * - decoding: Set by user
    1188. */
    1189. void *hwaccel_context;
    1190. /**
    1191. * error
    1192. * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
    1193. * - decoding: unused
    1194. */
    1195. uint64_t error[AV_NUM_DATA_POINTERS];
    1196. /**
    1197. * DCT algorithm, see FF_DCT_* below
    1198. * - encoding: Set by user.
    1199. * - decoding: unused
    1200. */
    1201. int dct_algo;
    1202. #define FF_DCT_AUTO 0
    1203. #define FF_DCT_FASTINT 1
    1204. #define FF_DCT_INT 2
    1205. #define FF_DCT_MMX 3
    1206. #define FF_DCT_ALTIVEC 5
    1207. #define FF_DCT_FAAN 6
    1208. /**
    1209. * IDCT algorithm, see FF_IDCT_* below.
    1210. * - encoding: Set by user.
    1211. * - decoding: Set by user.
    1212. */
    1213. int idct_algo;
    1214. #define FF_IDCT_AUTO 0
    1215. #define FF_IDCT_INT 1
    1216. #define FF_IDCT_SIMPLE 2
    1217. #define FF_IDCT_SIMPLEMMX 3
    1218. #define FF_IDCT_ARM 7
    1219. #define FF_IDCT_ALTIVEC 8
    1220. #if FF_API_ARCH_SH4
    1221. #define FF_IDCT_SH4 9
    1222. #endif
    1223. #define FF_IDCT_SIMPLEARM 10
    1224. #if FF_API_UNUSED_MEMBERS
    1225. #define FF_IDCT_IPP 13
    1226. #endif /* FF_API_UNUSED_MEMBERS */
    1227. #define FF_IDCT_XVID 14
    1228. #if FF_API_IDCT_XVIDMMX
    1229. #define FF_IDCT_XVIDMMX 14
    1230. #endif /* FF_API_IDCT_XVIDMMX */
    1231. #define FF_IDCT_SIMPLEARMV5TE 16
    1232. #define FF_IDCT_SIMPLEARMV6 17
    1233. #if FF_API_ARCH_SPARC
    1234. #define FF_IDCT_SIMPLEVIS 18
    1235. #endif
    1236. #define FF_IDCT_FAAN 20
    1237. #define FF_IDCT_SIMPLENEON 22
    1238. #if FF_API_ARCH_ALPHA
    1239. #define FF_IDCT_SIMPLEALPHA 23
    1240. #endif
    1241. #define FF_IDCT_SIMPLEAUTO 128
    1242. /**
    1243. * bits per sample/pixel from the demuxer (needed for huffyuv).
    1244. * - encoding: Set by libavcodec.
    1245. * - decoding: Set by user.
    1246. */
    1247. int bits_per_coded_sample;
    1248. /**
    1249. * Bits per sample/pixel of internal libavcodec pixel/sample format.
    1250. * - encoding: set by user.
    1251. * - decoding: set by libavcodec.
    1252. */
    1253. int bits_per_raw_sample;
    1254. #if FF_API_LOWRES
    1255. /**
    1256. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
    1257. * - encoding: unused
    1258. * - decoding: Set by user.
    1259. * Code outside libavcodec should access this field using:
    1260. * av_codec_{get,set}_lowres(avctx)
    1261. */
    1262. int lowres;
    1263. #endif
    1264. #if FF_API_CODED_FRAME
    1265. /**
    1266. * the picture in the bitstream
    1267. * - encoding: Set by libavcodec.
    1268. * - decoding: unused
    1269. *
    1270. * @deprecated use the quality factor packet side data instead
    1271. */
    1272. attribute_deprecated AVFrame *coded_frame;
    1273. #endif
    1274. /**
    1275. * thread count
    1276. * is used to decide how many independent tasks should be passed to execute()
    1277. * - encoding: Set by user.
    1278. * - decoding: Set by user.
    1279. */
    1280. int thread_count;
    1281. /**
    1282. * Which multithreading methods to use.
    1283. * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
    1284. * so clients which cannot provide future frames should not use it.
    1285. *
    1286. * - encoding: Set by user, otherwise the default is used.
    1287. * - decoding: Set by user, otherwise the default is used.
    1288. */
    1289. int thread_type;
    1290. #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
    1291. #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
    1292. /**
    1293. * Which multithreading methods are in use by the codec.
    1294. * - encoding: Set by libavcodec.
    1295. * - decoding: Set by libavcodec.
    1296. */
    1297. int active_thread_type;
    1298. /**
    1299. * Set by the client if its custom get_buffer() callback can be called
    1300. * synchronously from another thread, which allows faster multithreaded decoding.
    1301. * draw_horiz_band() will be called from other threads regardless of this setting.
    1302. * Ignored if the default get_buffer() is used.
    1303. * - encoding: Set by user.
    1304. * - decoding: Set by user.
    1305. */
    1306. int thread_safe_callbacks;
    1307. /**
    1308. * The codec may call this to execute several independent things.
    1309. * It will return only after finishing all tasks.
    1310. * The user may replace this with some multithreaded implementation,
    1311. * the default implementation will execute the parts serially.
    1312. * @param count the number of things to execute
    1313. * - encoding: Set by libavcodec, user can override.
    1314. * - decoding: Set by libavcodec, user can override.
    1315. */
    1316. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
    1317. /**
    1318. * The codec may call this to execute several independent things.
    1319. * It will return only after finishing all tasks.
    1320. * The user may replace this with some multithreaded implementation,
    1321. * the default implementation will execute the parts serially.
    1322. * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
    1323. * @param c context passed also to func
    1324. * @param count the number of things to execute
    1325. * @param arg2 argument passed unchanged to func
    1326. * @param ret return values of executed functions, must have space for "count" values. May be NULL.
    1327. * @param func function that will be called count times, with jobnr from 0 to count-1.
    1328. * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
    1329. * two instances of func executing at the same time will have the same threadnr.
    1330. * @return always 0 currently, but code should handle a future improvement where when any call to func
    1331. * returns < 0 no further calls to func may be done and < 0 is returned.
    1332. * - encoding: Set by libavcodec, user can override.
    1333. * - decoding: Set by libavcodec, user can override.
    1334. */
    1335. int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
    1336. /**
    1337. * noise vs. sse weight for the nsse comparison function
    1338. * - encoding: Set by user.
    1339. * - decoding: unused
    1340. */
    1341. int nsse_weight;
    1342. /**
    1343. * profile
    1344. * - encoding: Set by user.
    1345. * - decoding: Set by libavcodec.
    1346. */
    1347. int profile;
    1348. #define FF_PROFILE_UNKNOWN -99
    1349. #define FF_PROFILE_RESERVED -100
    1350. #define FF_PROFILE_AAC_MAIN 0
    1351. #define FF_PROFILE_AAC_LOW 1
    1352. #define FF_PROFILE_AAC_SSR 2
    1353. #define FF_PROFILE_AAC_LTP 3
    1354. #define FF_PROFILE_AAC_HE 4
    1355. #define FF_PROFILE_AAC_HE_V2 28
    1356. #define FF_PROFILE_AAC_LD 22
    1357. #define FF_PROFILE_AAC_ELD 38
    1358. #define FF_PROFILE_MPEG2_AAC_LOW 128
    1359. #define FF_PROFILE_MPEG2_AAC_HE 131
    1360. #define FF_PROFILE_DTS 20
    1361. #define FF_PROFILE_DTS_ES 30
    1362. #define FF_PROFILE_DTS_96_24 40
    1363. #define FF_PROFILE_DTS_HD_HRA 50
    1364. #define FF_PROFILE_DTS_HD_MA 60
    1365. #define FF_PROFILE_DTS_EXPRESS 70
    1366. #define FF_PROFILE_MPEG2_422 0
    1367. #define FF_PROFILE_MPEG2_HIGH 1
    1368. #define FF_PROFILE_MPEG2_SS 2
    1369. #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
    1370. #define FF_PROFILE_MPEG2_MAIN 4
    1371. #define FF_PROFILE_MPEG2_SIMPLE 5
    1372. #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
    1373. #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
    1374. #define FF_PROFILE_H264_BASELINE 66
    1375. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
    1376. #define FF_PROFILE_H264_MAIN 77
    1377. #define FF_PROFILE_H264_EXTENDED 88
    1378. #define FF_PROFILE_H264_HIGH 100
    1379. #define FF_PROFILE_H264_HIGH_10 110
    1380. #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
    1381. #define FF_PROFILE_H264_HIGH_422 122
    1382. #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
    1383. #define FF_PROFILE_H264_HIGH_444 144
    1384. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
    1385. #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
    1386. #define FF_PROFILE_H264_CAVLC_444 44
    1387. #define FF_PROFILE_VC1_SIMPLE 0
    1388. #define FF_PROFILE_VC1_MAIN 1
    1389. #define FF_PROFILE_VC1_COMPLEX 2
    1390. #define FF_PROFILE_VC1_ADVANCED 3
    1391. #define FF_PROFILE_MPEG4_SIMPLE 0
    1392. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
    1393. #define FF_PROFILE_MPEG4_CORE 2
    1394. #define FF_PROFILE_MPEG4_MAIN 3
    1395. #define FF_PROFILE_MPEG4_N_BIT 4
    1396. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
    1397. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
    1398. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
    1399. #define FF_PROFILE_MPEG4_HYBRID 8
    1400. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
    1401. #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
    1402. #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
    1403. #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
    1404. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
    1405. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
    1406. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
    1407. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
    1408. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
    1409. #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
    1410. #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
    1411. #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
    1412. #define FF_PROFILE_VP9_0 0
    1413. #define FF_PROFILE_VP9_1 1
    1414. #define FF_PROFILE_VP9_2 2
    1415. #define FF_PROFILE_VP9_3 3
    1416. #define FF_PROFILE_HEVC_MAIN 1
    1417. #define FF_PROFILE_HEVC_MAIN_10 2
    1418. #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
    1419. #define FF_PROFILE_HEVC_REXT 4
    1420. /**
    1421. * level
    1422. * - encoding: Set by user.
    1423. * - decoding: Set by libavcodec.
    1424. */
    1425. int level;
    1426. #define FF_LEVEL_UNKNOWN -99
    1427. /**
    1428. * Skip loop filtering for selected frames.
    1429. * - encoding: unused
    1430. * - decoding: Set by user.
    1431. */
    1432. enum AVDiscard skip_loop_filter;
    1433. /**
    1434. * Skip IDCT/dequantization for selected frames.
    1435. * - encoding: unused
    1436. * - decoding: Set by user.
    1437. */
    1438. enum AVDiscard skip_idct;
    1439. /**
    1440. * Skip decoding for selected frames.
    1441. * - encoding: unused
    1442. * - decoding: Set by user.
    1443. */
    1444. enum AVDiscard skip_frame;
    1445. /**
    1446. * Header containing style information for text subtitles.
    1447. * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
    1448. * [Script Info] and [V4+ Styles] section, plus the [Events] line and
    1449. * the Format line following. It shouldn't include any Dialogue line.
    1450. * - encoding: Set/allocated/freed by user (before avcodec_open2())
    1451. * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
    1452. */
    1453. uint8_t *subtitle_header;
    1454. int subtitle_header_size;
    1455. #if FF_API_ERROR_RATE
    1456. /**
    1457. * @deprecated use the 'error_rate' private AVOption of the mpegvideo
    1458. * encoders
    1459. */
    1460. attribute_deprecated
    1461. int error_rate;
    1462. #endif
    1463. #if FF_API_VBV_DELAY
    1464. /**
    1465. * VBV delay coded in the last frame (in periods of a 27 MHz clock).
    1466. * Used for compliant TS muxing.
    1467. * - encoding: Set by libavcodec.
    1468. * - decoding: unused.
    1469. * @deprecated this value is now exported as a part of
    1470. * AV_PKT_DATA_CPB_PROPERTIES packet side data
    1471. */
    1472. attribute_deprecated
    1473. uint64_t vbv_delay;
    1474. #endif
    1475. #if FF_API_SIDEDATA_ONLY_PKT
    1476. /**
    1477. * Encoding only and set by default. Allow encoders to output packets
    1478. * that do not contain any encoded data, only side data.
    1479. *
    1480. * Some encoders need to output such packets, e.g. to update some stream
    1481. * parameters at the end of encoding.
    1482. *
    1483. * @deprecated this field disables the default behaviour and
    1484. * it is kept only for compatibility.
    1485. */
    1486. attribute_deprecated
    1487. int side_data_only_packets;
    1488. #endif
    1489. /**
    1490. * Audio only. The number of "priming" samples (padding) inserted by the
    1491. * encoder at the beginning of the audio. I.e. this number of leading
    1492. * decoded samples must be discarded by the caller to get the original audio
    1493. * without leading padding.
    1494. *
    1495. * - decoding: unused
    1496. * - encoding: Set by libavcodec. The timestamps on the output packets are
    1497. * adjusted by the encoder so that they always refer to the
    1498. * first sample of the data actually contained in the packet,
    1499. * including any added padding. E.g. if the timebase is
    1500. * 1/samplerate and the timestamp of the first input sample is
    1501. * 0, the timestamp of the first output packet will be
    1502. * -initial_padding.
    1503. */
    1504. int initial_padding;
    1505. /**
    1506. * - decoding: For codecs that store a framerate value in the compressed
    1507. * bitstream, the decoder may export it here. { 0, 1} when
    1508. * unknown.
    1509. * - encoding: May be used to signal the framerate of CFR content to an
    1510. * encoder.
    1511. */
    1512. AVRational framerate;
    1513. /**
    1514. * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
    1515. * - encoding: unused.
    1516. * - decoding: Set by libavcodec before calling get_format()
    1517. */
    1518. enum AVPixelFormat sw_pix_fmt;
    1519. /**
    1520. * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
    1521. * Code outside libavcodec should access this field using:
    1522. * av_codec_{get,set}_pkt_timebase(avctx)
    1523. * - encoding unused.
    1524. * - decoding set by user.
    1525. */
    1526. AVRational pkt_timebase;
    1527. /**
    1528. * AVCodecDescriptor
    1529. * Code outside libavcodec should access this field using:
    1530. * av_codec_{get,set}_codec_descriptor(avctx)
    1531. * - encoding: unused.
    1532. * - decoding: set by libavcodec.
    1533. */
    1534. const AVCodecDescriptor *codec_descriptor;
    1535. #if !FF_API_LOWRES
    1536. /**
    1537. * low resolution decoding, 1-> 1/2 size, 2->1/4 size
    1538. * - encoding: unused
    1539. * - decoding: Set by user.
    1540. * Code outside libavcodec should access this field using:
    1541. * av_codec_{get,set}_lowres(avctx)
    1542. */
    1543. int lowres;
    1544. #endif
    1545. /**
    1546. * Current statistics for PTS correction.
    1547. * - decoding: maintained and used by libavcodec, not intended to be used by user apps
    1548. * - encoding: unused
    1549. */
    1550. int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
    1551. int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
    1552. int64_t pts_correction_last_pts; /// PTS of the last frame
    1553. int64_t pts_correction_last_dts; /// DTS of the last frame
    1554. /**
    1555. * Character encoding of the input subtitles file.
    1556. * - decoding: set by user
    1557. * - encoding: unused
    1558. */
    1559. char *sub_charenc;
    1560. /**
    1561. * Subtitles character encoding mode. Formats or codecs might be adjusting
    1562. * this setting (if they are doing the conversion themselves for instance).
    1563. * - decoding: set by libavcodec
    1564. * - encoding: unused
    1565. */
    1566. int sub_charenc_mode;
    1567. #define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)
    1568. #define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself
    1569. #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv
    1570. /**
    1571. * Skip processing alpha if supported by codec.
    1572. * Note that if the format uses pre-multiplied alpha (common with VP6,
    1573. * and recommended due to better video quality/compression)
    1574. * the image will look as if alpha-blended onto a black background.
    1575. * However for formats that do not use pre-multiplied alpha
    1576. * there might be serious artefacts (though e.g. libswscale currently
    1577. * assumes pre-multiplied alpha anyway).
    1578. * Code outside libavcodec should access this field using AVOptions
    1579. *
    1580. * - decoding: set by user
    1581. * - encoding: unused
    1582. */
    1583. int skip_alpha;
    1584. /**
    1585. * Number of samples to skip after a discontinuity
    1586. * - decoding: unused
    1587. * - encoding: set by libavcodec
    1588. */
    1589. int seek_preroll;
    1590. #if !FF_API_DEBUG_MV
    1591. /**
    1592. * debug motion vectors
    1593. * Code outside libavcodec should access this field using AVOptions
    1594. * - encoding: Set by user.
    1595. * - decoding: Set by user.
    1596. */
    1597. int debug_mv;
    1598. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
    1599. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
    1600. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
    1601. #endif
    1602. /**
    1603. * custom intra quantization matrix
    1604. * Code outside libavcodec should access this field using av_codec_g/set_chroma_intra_matrix()
    1605. * - encoding: Set by user, can be NULL.
    1606. * - decoding: unused.
    1607. */
    1608. uint16_t *chroma_intra_matrix;
    1609. /**
    1610. * dump format separator.
    1611. * can be ", " or "\n " or anything else
    1612. * Code outside libavcodec should access this field using AVOptions
    1613. * (NO direct access).
    1614. * - encoding: Set by user.
    1615. * - decoding: Set by user.
    1616. */
    1617. uint8_t *dump_separator;
    1618. /**
    1619. * ',' separated list of allowed decoders.
    1620. * If NULL then all are allowed
    1621. * - encoding: unused
    1622. * - decoding: set by user through AVOPtions (NO direct access)
    1623. */
    1624. char *codec_whitelist;
    1625. /*
    1626. * Properties of the stream that gets decoded
    1627. * To be accessed through av_codec_get_properties() (NO direct access)
    1628. * - encoding: unused
    1629. * - decoding: set by libavcodec
    1630. */
    1631. unsigned properties;
    1632. #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001
    1633. #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
    1634. /**
    1635. * Additional data associated with the entire coded stream.
    1636. *
    1637. * - decoding: unused
    1638. * - encoding: may be set by libavcodec after avcodec_open2().
    1639. */
    1640. AVPacketSideData *coded_side_data;
    1641. int nb_coded_side_data;
    1642. /**
    1643. * Encoding only.
    1644. *
    1645. * For hardware encoders configured to use a hwaccel pixel format, this
    1646. * field should be set by the caller to a reference to the AVHWFramesContext
    1647. * describing input frames. AVHWFramesContext.format must be equal to
    1648. * AVCodecContext.pix_fmt.
    1649. *
    1650. * This field should be set before avcodec_open2() is called and is
    1651. * afterwards owned and managed by libavcodec.
    1652. */
    1653. AVBufferRef *hw_frames_ctx;
    1654. /**
    1655. * Control the form of AVSubtitle.rects[N]->ass
    1656. * - decoding: set by user
    1657. * - encoding: unused
    1658. */
    1659. int sub_text_format;
    1660. #define FF_SUB_TEXT_FMT_ASS 0
    1661. #if FF_API_ASS_TIMING
    1662. #define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1
    1663. #endif
    1664. } AVCodecContext;
    • int width, height; 视频有关,画面宽高
    • int coded_width, coded_height; 码流宽高,不同于width/height,当解码出来帧在裁剪出来前输出时画面
    • int gop_size; (group of pictures) GOP画面组大小
    • int max_b_frames; B帧最大值
    • int has_b_frames; 解码器的帧重新排序缓冲区的大小,MPEG-2 1个IBP
    • int sample_rate; 音频采样率
    • int channels; 声道数目
    • enum AVSampleFormat sample_fmt; 音频采样格式,枚举类型

      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. };
    • int frame_size; 一个音频帧里每个声道采样数目

    • int frame_number; 帧数目,解码时是解码器总解码的帧数目,编码时是编码过的帧数目
    • int (get_buffer2)(struct AVCodecContext s, AVFrame *frame, int flags);这个回调被调用,当从buffer中得到每帧的数据时,每个buffer必须使用AVBuffer API进行引用技数

    如下属性将被设置在callback回调之前

    • format
    • width, height(视频)
    • sample_rate, channel_layout, nb_samples(音频)

    如约智惠.png