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

1567 lines
44KB

  1. #ifndef AVCODEC_H
  2. #define AVCODEC_H
  3. /**
  4. * @file avcodec.h
  5. * external api header.
  6. */
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include "common.h"
  11. #define LIBAVCODEC_VERSION_INT 0x000406
  12. #define LIBAVCODEC_VERSION "0.4.6"
  13. #define LIBAVCODEC_BUILD 4671
  14. #define LIBAVCODEC_BUILD_STR "4671"
  15. #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
  16. enum CodecID {
  17. CODEC_ID_NONE,
  18. CODEC_ID_MPEG1VIDEO,
  19. CODEC_ID_H263,
  20. CODEC_ID_RV10,
  21. CODEC_ID_MP2,
  22. CODEC_ID_MP3LAME,
  23. CODEC_ID_VORBIS,
  24. CODEC_ID_AC3,
  25. CODEC_ID_MJPEG,
  26. CODEC_ID_MJPEGB,
  27. CODEC_ID_LJPEG,
  28. CODEC_ID_MPEG4,
  29. CODEC_ID_RAWVIDEO,
  30. CODEC_ID_MSMPEG4V1,
  31. CODEC_ID_MSMPEG4V2,
  32. CODEC_ID_MSMPEG4V3,
  33. CODEC_ID_WMV1,
  34. CODEC_ID_WMV2,
  35. CODEC_ID_H263P,
  36. CODEC_ID_H263I,
  37. CODEC_ID_FLV1,
  38. CODEC_ID_SVQ1,
  39. CODEC_ID_SVQ3,
  40. CODEC_ID_DVVIDEO,
  41. CODEC_ID_DVAUDIO,
  42. CODEC_ID_WMAV1,
  43. CODEC_ID_WMAV2,
  44. CODEC_ID_MACE3,
  45. CODEC_ID_MACE6,
  46. CODEC_ID_HUFFYUV,
  47. CODEC_ID_CYUV,
  48. CODEC_ID_H264,
  49. CODEC_ID_INDEO3,
  50. CODEC_ID_VP3,
  51. CODEC_ID_AAC,
  52. CODEC_ID_MPEG4AAC,
  53. CODEC_ID_ASV1,
  54. CODEC_ID_FFV1,
  55. CODEC_ID_4XM,
  56. CODEC_ID_VCR1,
  57. /* various pcm "codecs" */
  58. CODEC_ID_PCM_S16LE,
  59. CODEC_ID_PCM_S16BE,
  60. CODEC_ID_PCM_U16LE,
  61. CODEC_ID_PCM_U16BE,
  62. CODEC_ID_PCM_S8,
  63. CODEC_ID_PCM_U8,
  64. CODEC_ID_PCM_MULAW,
  65. CODEC_ID_PCM_ALAW,
  66. /* various adpcm codecs */
  67. CODEC_ID_ADPCM_IMA_QT,
  68. CODEC_ID_ADPCM_IMA_WAV,
  69. CODEC_ID_ADPCM_MS,
  70. CODEC_ID_ADPCM_4XM,
  71. /* AMR */
  72. CODEC_ID_AMR_NB,
  73. /* RealAudio codecs*/
  74. CODEC_ID_RA_144,
  75. CODEC_ID_RA_288,
  76. };
  77. enum CodecType {
  78. CODEC_TYPE_UNKNOWN = -1,
  79. CODEC_TYPE_VIDEO,
  80. CODEC_TYPE_AUDIO,
  81. };
  82. /**
  83. * Pixel format.
  84. */
  85. enum PixelFormat {
  86. PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
  87. PIX_FMT_YUV422,
  88. PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB...
  89. PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR...
  90. PIX_FMT_YUV422P, ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
  91. PIX_FMT_YUV444P, ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
  92. PIX_FMT_RGBA32, ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
  93. PIX_FMT_YUV410P, ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
  94. PIX_FMT_YUV411P, ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
  95. PIX_FMT_RGB565, ///< always stored in cpu endianness
  96. PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
  97. PIX_FMT_GRAY8,
  98. PIX_FMT_MONOWHITE, ///< 0 is white
  99. PIX_FMT_MONOBLACK, ///< 0 is black
  100. PIX_FMT_PAL8, ///< 8 bit with RGBA palette
  101. PIX_FMT_YUVJ420P, ///< Planar YUV 4:2:0 full scale (jpeg)
  102. PIX_FMT_YUVJ422P, ///< Planar YUV 4:2:2 full scale (jpeg)
  103. PIX_FMT_YUVJ444P, ///< Planar YUV 4:4:4 full scale (jpeg)
  104. PIX_FMT_NB,
  105. };
  106. /* currently unused, may be used if 24/32 bits samples ever supported */
  107. enum SampleFormat {
  108. SAMPLE_FMT_S16 = 0, ///< signed 16 bits
  109. };
  110. /* in bytes */
  111. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
  112. /**
  113. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  114. * this is mainly needed because some optimized bitstream readers read
  115. * 32 or 64 bit at once and could read over the end<br>
  116. * Note, if the first 23 bits of the additional bytes are not 0 then damaged
  117. * MPEG bitstreams could cause overread and segfault
  118. */
  119. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  120. /* motion estimation type, EPZS by default */
  121. enum Motion_Est_ID {
  122. ME_ZERO = 1,
  123. ME_FULL,
  124. ME_LOG,
  125. ME_PHODS,
  126. ME_EPZS,
  127. ME_X1
  128. };
  129. typedef struct RcOverride{
  130. int start_frame;
  131. int end_frame;
  132. int qscale; // if this is 0 then quality_factor will be used instead
  133. float quality_factor;
  134. } RcOverride;
  135. /* only for ME compatiblity with old apps */
  136. extern int motion_estimation_method;
  137. /* ME algos sorted by quality */
  138. static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
  139. ME_X1, ME_EPZS, ME_FULL };
  140. #define FF_MAX_B_FRAMES 8
  141. /* encoding support
  142. these flags can be passed in AVCodecContext.flags before initing
  143. Note: note not everything is supported yet
  144. */
  145. #define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
  146. #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
  147. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
  148. #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
  149. #define CODEC_FLAG_GMC 0x0020 ///< use GMC
  150. #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
  151. /* parent program gurantees that the input for b-frame containing streams is not written to
  152. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  153. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  154. #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
  155. #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
  156. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
  157. #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
  158. #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
  159. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
  160. #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
  161. of only at frame boundaries */
  162. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
  163. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
  164. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
  165. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
  166. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
  167. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
  168. #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
  169. /* Fx : Flag for h263+ extra options */
  170. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
  171. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
  172. /* For advanced prediction mode, we reuse the 4MV flag */
  173. /* Unsupported options :
  174. * Syntax Arithmetic coding (SAC)
  175. * Deblocking filter internal loop
  176. * Slice structured
  177. * Reference Picture Selection
  178. * Independant Segment Decoding
  179. * Alternative Inter * VLC
  180. * Modified Quantization */
  181. /* /Fx */
  182. /* codec capabilities */
  183. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
  184. /**
  185. * Codec uses get_buffer() for allocating buffers.
  186. * direct rendering method 1
  187. */
  188. #define CODEC_CAP_DR1 0x0002
  189. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  190. used */
  191. #define CODEC_CAP_PARSE_ONLY 0x0004
  192. #define CODEC_CAP_TRUNCATED 0x0008
  193. #define FF_COMMON_FRAME \
  194. /**\
  195. * pointer to the picture planes.\
  196. * this might be different from the first allocated byte\
  197. * - encoding: \
  198. * - decoding: \
  199. */\
  200. uint8_t *data[4];\
  201. int linesize[4];\
  202. /**\
  203. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  204. * this isnt used by lavc unless the default get/release_buffer() is used\
  205. * - encoding: \
  206. * - decoding: \
  207. */\
  208. uint8_t *base[4];\
  209. /**\
  210. * 1 -> keyframe, 0-> not\
  211. * - encoding: set by lavc\
  212. * - decoding: set by lavc\
  213. */\
  214. int key_frame;\
  215. \
  216. /**\
  217. * picture type of the frame, see ?_TYPE below.\
  218. * - encoding: set by lavc for coded_picture (and set by user for input)\
  219. * - decoding: set by lavc\
  220. */\
  221. int pict_type;\
  222. \
  223. /**\
  224. * presentation timestamp in micro seconds (time when frame should be shown to user)\
  225. * if 0 then the frame_rate will be used as reference\
  226. * - encoding: MUST be set by user\
  227. * - decoding: set by lavc\
  228. */\
  229. int64_t pts;\
  230. \
  231. /**\
  232. * picture number in bitstream order.\
  233. * - encoding: set by\
  234. * - decoding: set by lavc\
  235. */\
  236. int coded_picture_number;\
  237. /**\
  238. * picture number in display order.\
  239. * - encoding: set by\
  240. * - decoding: set by lavc\
  241. */\
  242. int display_picture_number;\
  243. \
  244. /**\
  245. * quality (between 1 (good) and 31 (bad)) \
  246. * - encoding: set by lavc for coded_picture (and set by user for input)\
  247. * - decoding: set by lavc\
  248. */\
  249. float quality; \
  250. \
  251. /**\
  252. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  253. * set to something large if the buffer has not been used yet \
  254. * - encoding: unused\
  255. * - decoding: MUST be set by get_buffer()\
  256. */\
  257. int age;\
  258. \
  259. /**\
  260. * is this picture used as reference\
  261. * - encoding: unused\
  262. * - decoding: set by lavc (before get_buffer() call))\
  263. */\
  264. int reference;\
  265. \
  266. /**\
  267. * QP table\
  268. * - encoding: unused\
  269. * - decoding: set by lavc\
  270. */\
  271. int8_t *qscale_table;\
  272. /**\
  273. * QP store stride\
  274. * - encoding: unused\
  275. * - decoding: set by lavc\
  276. */\
  277. int qstride;\
  278. \
  279. /**\
  280. * mbskip_table[mb]>=1 if MB didnt change\
  281. * stride= mb_width = (width+15)>>4\
  282. * - encoding: unused\
  283. * - decoding: set by lavc\
  284. */\
  285. uint8_t *mbskip_table;\
  286. \
  287. /**\
  288. * for some private data of the user\
  289. * - encoding: unused\
  290. * - decoding: set by user\
  291. */\
  292. void *opaque;\
  293. \
  294. /**\
  295. * error\
  296. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  297. * - decoding: unused\
  298. */\
  299. uint64_t error[4];\
  300. \
  301. /**\
  302. * type of the buffer (to keep track of who has to dealloc data[*])\
  303. * - encoding: set by the one who allocs it\
  304. * - decoding: set by the one who allocs it\
  305. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  306. */\
  307. int type;\
  308. \
  309. /**\
  310. * when decoding, this signal how much the picture must be delayed.\
  311. * extra_delay = repeat_pict / (2*fps)\
  312. * - encoding: unused\
  313. * - decoding: set by lavc\
  314. */\
  315. int repeat_pict;\
  316. \
  317. /**\
  318. * \
  319. */\
  320. int qscale_type;\
  321. #define FF_QSCALE_TYPE_MPEG1 0
  322. #define FF_QSCALE_TYPE_MPEG2 1
  323. #define FF_BUFFER_TYPE_INTERNAL 1
  324. #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
  325. #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
  326. #define FF_I_TYPE 1 // Intra
  327. #define FF_P_TYPE 2 // Predicted
  328. #define FF_B_TYPE 3 // Bi-dir predicted
  329. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  330. #define FF_SI_TYPE 5
  331. #define FF_SP_TYPE 6
  332. /**
  333. * Audio Video Frame.
  334. */
  335. typedef struct AVFrame {
  336. FF_COMMON_FRAME
  337. } AVFrame;
  338. #define DEFAULT_FRAME_RATE_BASE 1001000
  339. /**
  340. * main external api structure.
  341. */
  342. typedef struct AVCodecContext {
  343. /**
  344. * the average bitrate.
  345. * - encoding: set by user. unused for constant quantizer encoding
  346. * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  347. */
  348. int bit_rate;
  349. /**
  350. * number of bits the bitstream is allowed to diverge from the reference.
  351. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  352. * - encoding: set by user. unused for constant quantizer encoding
  353. * - decoding: unused
  354. */
  355. int bit_rate_tolerance;
  356. /**
  357. * CODEC_FLAG_*.
  358. * - encoding: set by user.
  359. * - decoding: set by user.
  360. */
  361. int flags;
  362. /**
  363. * some codecs needs additionnal format info. It is stored here
  364. * - encoding: set by user.
  365. * - decoding: set by lavc. (FIXME is this ok?)
  366. */
  367. int sub_id;
  368. /**
  369. * motion estimation algorithm used for video coding.
  370. * - encoding: MUST be set by user.
  371. * - decoding: unused
  372. */
  373. int me_method;
  374. /**
  375. * some codecs need / can use extra-data like huffman tables.
  376. * mjpeg: huffman tables
  377. * rv10: additional flags
  378. * mpeg4: global headers (they can be in the bitstream or here)
  379. * - encoding: set/allocated/freed by lavc.
  380. * - decoding: set/allocated/freed by user.
  381. */
  382. void *extradata;
  383. int extradata_size;
  384. /* video only */
  385. /**
  386. * frames per sec multiplied by frame_rate_base.
  387. * for variable fps this is the precission, so if the timestamps
  388. * can be specified in msec precssion then this is 1000*frame_rate_base
  389. * - encoding: MUST be set by user
  390. * - decoding: set by lavc. 0 or the frame_rate if available
  391. */
  392. int frame_rate;
  393. /**
  394. * width / height.
  395. * - encoding: MUST be set by user.
  396. * - decoding: set by user, some codecs might override / change it during playback
  397. */
  398. int width, height;
  399. #define FF_ASPECT_SQUARE 1
  400. #define FF_ASPECT_4_3_625 2
  401. #define FF_ASPECT_4_3_525 3
  402. #define FF_ASPECT_16_9_625 4
  403. #define FF_ASPECT_16_9_525 5
  404. #define FF_ASPECT_EXTENDED 15
  405. /**
  406. * the number of pictures in a group of pitures, or 0 for intra_only.
  407. * - encoding: set by user.
  408. * - decoding: unused
  409. */
  410. int gop_size;
  411. /**
  412. * pixel format, see PIX_FMT_xxx.
  413. * - encoding: unused
  414. * - decoding: set by lavc.
  415. */
  416. enum PixelFormat pix_fmt;
  417. /**
  418. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  419. * has to read frames at native frame rate.
  420. * - encoding: set by user.
  421. * - decoding: unused.
  422. */
  423. int rate_emu;
  424. /**
  425. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  426. * decoder to draw an horizontal band. It improve cache usage. Not
  427. * all codecs can do that. You must check the codec capabilities
  428. * before
  429. * - encoding: unused
  430. * - decoding: set by user.
  431. * @param height the height of the slice
  432. * @param y the y position of the slice
  433. * @param type 1->top field, 2->bottom field, 3->frame
  434. * @param offset offset into the AVFrame.data from which the slice should be read
  435. */
  436. void (*draw_horiz_band)(struct AVCodecContext *s,
  437. AVFrame *src, int offset[4],
  438. int y, int type, int height);
  439. /* audio only */
  440. int sample_rate; ///< samples per sec
  441. int channels;
  442. int sample_fmt; ///< sample format, currenly unused
  443. /* the following data should not be initialized */
  444. int frame_size; ///< in samples, initialized when calling 'init'
  445. int frame_number; ///< audio or video frame number
  446. int real_pict_num; ///< returns the real picture number of previous encoded frame
  447. /**
  448. * number of frames the decoded output will be delayed relative to
  449. * the encoded input.
  450. * - encoding: set by lavc.
  451. * - decoding: unused
  452. */
  453. int delay;
  454. /* - encoding parameters */
  455. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  456. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  457. /**
  458. * minimum quantizer.
  459. * - encoding: set by user.
  460. * - decoding: unused
  461. */
  462. int qmin;
  463. /**
  464. * maximum quantizer.
  465. * - encoding: set by user.
  466. * - decoding: unused
  467. */
  468. int qmax;
  469. /**
  470. * maximum quantizer difference etween frames.
  471. * - encoding: set by user.
  472. * - decoding: unused
  473. */
  474. int max_qdiff;
  475. /**
  476. * maximum number of b frames between non b frames.
  477. * note: the output will be delayed by max_b_frames+1 relative to the input
  478. * - encoding: set by user.
  479. * - decoding: unused
  480. */
  481. int max_b_frames;
  482. /**
  483. * qscale factor between ip and b frames.
  484. * - encoding: set by user.
  485. * - decoding: unused
  486. */
  487. float b_quant_factor;
  488. /** obsolete FIXME remove */
  489. int rc_strategy;
  490. int b_frame_strategy;
  491. /**
  492. * hurry up amount.
  493. * - encoding: unused
  494. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  495. */
  496. int hurry_up;
  497. struct AVCodec *codec;
  498. void *priv_data;
  499. /* The following data is for RTP friendly coding */
  500. /* By now only H.263/H.263+/MPEG4 coder honours this */
  501. int rtp_mode; /* 1 for activate RTP friendly-mode */
  502. /* highers numbers represent more error-prone */
  503. /* enviroments, by now just "1" exist */
  504. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  505. /* do it's best to deliver a chunk with size */
  506. /* below rtp_payload_size, the chunk will start */
  507. /* with a start code on some codecs like H.263 */
  508. /* This doesn't take account of any particular */
  509. /* headers inside the transmited RTP payload */
  510. /* The RTP callcack: This function is called */
  511. /* every time the encoder as a packet to send */
  512. /* Depends on the encoder if the data starts */
  513. /* with a Start Code (it should) H.263 does */
  514. void (*rtp_callback)(void *data, int size, int packet_number);
  515. /* statistics, used for 2-pass encoding */
  516. int mv_bits;
  517. int header_bits;
  518. int i_tex_bits;
  519. int p_tex_bits;
  520. int i_count;
  521. int p_count;
  522. int skip_count;
  523. int misc_bits;
  524. /**
  525. * number of bits used for the previously encoded frame.
  526. * - encoding: set by lavc
  527. * - decoding: unused
  528. */
  529. int frame_bits;
  530. /**
  531. * private data of the user, can be used to carry app specific stuff.
  532. * - encoding: set by user
  533. * - decoding: set by user
  534. */
  535. void *opaque;
  536. char codec_name[32];
  537. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  538. enum CodecID codec_id; /* see CODEC_ID_xxx */
  539. /**
  540. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  541. * this is used to workaround some encoder bugs
  542. * - encoding: unused
  543. * - decoding: set by user, will be converted to upper case by lavc during init
  544. */
  545. unsigned int codec_tag;
  546. /**
  547. * workaround bugs in encoders which sometimes cannot be detected automatically.
  548. * - encoding: unused
  549. * - decoding: set by user
  550. */
  551. int workaround_bugs;
  552. #define FF_BUG_AUTODETECT 1 ///< autodetection
  553. #define FF_BUG_OLD_MSMPEG4 2
  554. #define FF_BUG_XVID_ILACE 4
  555. #define FF_BUG_UMP4 8
  556. #define FF_BUG_NO_PADDING 16
  557. #define FF_BUG_AC_VLC 32
  558. #define FF_BUG_QPEL_CHROMA 64
  559. #define FF_BUG_STD_QPEL 128
  560. #define FF_BUG_QPEL_CHROMA2 256
  561. #define FF_BUG_DIRECT_BLOCKSIZE 512
  562. #define FF_BUG_EDGE 1024
  563. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  564. /**
  565. * luma single coeff elimination threshold.
  566. * - encoding: set by user
  567. * - decoding: unused
  568. */
  569. int luma_elim_threshold;
  570. /**
  571. * chroma single coeff elimination threshold.
  572. * - encoding: set by user
  573. * - decoding: unused
  574. */
  575. int chroma_elim_threshold;
  576. /**
  577. * strictly follow the std (MPEG4, ...).
  578. * - encoding: set by user
  579. * - decoding: unused
  580. */
  581. int strict_std_compliance;
  582. /**
  583. * qscale offset between ip and b frames.
  584. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  585. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  586. * - encoding: set by user.
  587. * - decoding: unused
  588. */
  589. float b_quant_offset;
  590. /**
  591. * error resilience higher values will detect more errors but may missdetect
  592. * some more or less valid parts as errors.
  593. * - encoding: unused
  594. * - decoding: set by user
  595. */
  596. int error_resilience;
  597. #define FF_ER_CAREFULL 1
  598. #define FF_ER_COMPLIANT 2
  599. #define FF_ER_AGGRESSIVE 3
  600. #define FF_ER_VERY_AGGRESSIVE 4
  601. /**
  602. * called at the beginning of each frame to get a buffer for it.
  603. * if pic.reference is set then the frame will be read later by lavc
  604. * width and height should be rounded up to the next multiple of 16
  605. * - encoding: unused
  606. * - decoding: set by lavc, user can override
  607. */
  608. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  609. /**
  610. * called to release buffers which where allocated with get_buffer.
  611. * a released buffer can be reused in get_buffer()
  612. * pic.data[*] must be set to NULL
  613. * - encoding: unused
  614. * - decoding: set by lavc, user can override
  615. */
  616. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  617. /**
  618. * is 1 if the decoded stream contains b frames, 0 otherwise.
  619. * - encoding: unused
  620. * - decoding: set by lavc
  621. */
  622. int has_b_frames;
  623. int block_align; ///< used by some WAV based audio codecs
  624. int parse_only; /* - decoding only: if true, only parsing is done
  625. (function avcodec_parse_frame()). The frame
  626. data is returned. Only MPEG codecs support this now. */
  627. /**
  628. * 0-> h263 quant 1-> mpeg quant.
  629. * - encoding: set by user.
  630. * - decoding: unused
  631. */
  632. int mpeg_quant;
  633. /**
  634. * pass1 encoding statistics output buffer.
  635. * - encoding: set by lavc
  636. * - decoding: unused
  637. */
  638. char *stats_out;
  639. /**
  640. * pass2 encoding statistics input buffer.
  641. * concatenated stuff from stats_out of pass1 should be placed here
  642. * - encoding: allocated/set/freed by user
  643. * - decoding: unused
  644. */
  645. char *stats_in;
  646. /**
  647. * ratecontrol qmin qmax limiting method.
  648. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  649. * - encoding: set by user.
  650. * - decoding: unused
  651. */
  652. float rc_qsquish;
  653. float rc_qmod_amp;
  654. int rc_qmod_freq;
  655. /**
  656. * ratecontrol override, see RcOverride.
  657. * - encoding: allocated/set/freed by user.
  658. * - decoding: unused
  659. */
  660. RcOverride *rc_override;
  661. int rc_override_count;
  662. /**
  663. * rate control equation.
  664. * - encoding: set by user
  665. * - decoding: unused
  666. */
  667. char *rc_eq;
  668. /**
  669. * maximum bitrate.
  670. * - encoding: set by user.
  671. * - decoding: unused
  672. */
  673. int rc_max_rate;
  674. /**
  675. * minimum bitrate.
  676. * - encoding: set by user.
  677. * - decoding: unused
  678. */
  679. int rc_min_rate;
  680. /**
  681. * decoder bitstream buffer size.
  682. * - encoding: set by user.
  683. * - decoding: unused
  684. */
  685. int rc_buffer_size;
  686. float rc_buffer_aggressivity;
  687. /**
  688. * qscale factor between p and i frames.
  689. * - encoding: set by user.
  690. * - decoding: unused
  691. */
  692. float i_quant_factor;
  693. /**
  694. * qscale offset between p and i frames.
  695. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  696. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  697. * - encoding: set by user.
  698. * - decoding: unused
  699. */
  700. float i_quant_offset;
  701. /**
  702. * initial complexity for pass1 ratecontrol.
  703. * - encoding: set by user.
  704. * - decoding: unused
  705. */
  706. float rc_initial_cplx;
  707. /**
  708. * dct algorithm, see FF_DCT_* below.
  709. * - encoding: set by user
  710. * - decoding: unused
  711. */
  712. int dct_algo;
  713. #define FF_DCT_AUTO 0
  714. #define FF_DCT_FASTINT 1
  715. #define FF_DCT_INT 2
  716. #define FF_DCT_MMX 3
  717. #define FF_DCT_MLIB 4
  718. #define FF_DCT_ALTIVEC 5
  719. /**
  720. * luminance masking (0-> disabled).
  721. * - encoding: set by user
  722. * - decoding: unused
  723. */
  724. float lumi_masking;
  725. /**
  726. * temporary complexity masking (0-> disabled).
  727. * - encoding: set by user
  728. * - decoding: unused
  729. */
  730. float temporal_cplx_masking;
  731. /**
  732. * spatial complexity masking (0-> disabled).
  733. * - encoding: set by user
  734. * - decoding: unused
  735. */
  736. float spatial_cplx_masking;
  737. /**
  738. * p block masking (0-> disabled).
  739. * - encoding: set by user
  740. * - decoding: unused
  741. */
  742. float p_masking;
  743. /**
  744. * darkness masking (0-> disabled).
  745. * - encoding: set by user
  746. * - decoding: unused
  747. */
  748. float dark_masking;
  749. /* for binary compatibility */
  750. int unused;
  751. /**
  752. * idct algorithm, see FF_IDCT_* below.
  753. * - encoding: set by user
  754. * - decoding: set by user
  755. */
  756. int idct_algo;
  757. #define FF_IDCT_AUTO 0
  758. #define FF_IDCT_INT 1
  759. #define FF_IDCT_SIMPLE 2
  760. #define FF_IDCT_SIMPLEMMX 3
  761. #define FF_IDCT_LIBMPEG2MMX 4
  762. #define FF_IDCT_PS2 5
  763. #define FF_IDCT_MLIB 6
  764. #define FF_IDCT_ARM 7
  765. #define FF_IDCT_ALTIVEC 8
  766. #define FF_IDCT_SH4 9
  767. #define FF_IDCT_SIMPLEARM 10
  768. /**
  769. * slice count.
  770. * - encoding: set by lavc
  771. * - decoding: set by user (or 0)
  772. */
  773. int slice_count;
  774. /**
  775. * slice offsets in the frame in bytes.
  776. * - encoding: set/allocated by lavc
  777. * - decoding: set/allocated by user (or NULL)
  778. */
  779. int *slice_offset;
  780. /**
  781. * error concealment flags.
  782. * - encoding: unused
  783. * - decoding: set by user
  784. */
  785. int error_concealment;
  786. #define FF_EC_GUESS_MVS 1
  787. #define FF_EC_DEBLOCK 2
  788. /**
  789. * dsp_mask could be add used to disable unwanted CPU features
  790. * CPU features (i.e. MMX, SSE. ...)
  791. *
  792. * with FORCE flag you may instead enable given CPU features
  793. * (Dangerous: usable in case of misdetection, improper usage however will
  794. * result into program crash)
  795. */
  796. unsigned dsp_mask;
  797. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  798. /* lower 16 bits - CPU features */
  799. #ifdef HAVE_MMX
  800. #define FF_MM_MMX 0x0001 /* standard MMX */
  801. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  802. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  803. #define FF_MM_SSE 0x0008 /* SSE functions */
  804. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  805. #endif /* HAVE_MMX */
  806. /**
  807. * bits per sample/pixel from the demuxer (needed for huffyuv).
  808. * - encoding: set by lavc
  809. * - decoding: set by user
  810. */
  811. int bits_per_sample;
  812. /**
  813. * prediction method (needed for huffyuv).
  814. * - encoding: set by user
  815. * - decoding: unused
  816. */
  817. int prediction_method;
  818. #define FF_PRED_LEFT 0
  819. #define FF_PRED_PLANE 1
  820. #define FF_PRED_MEDIAN 2
  821. /**
  822. * aspect ratio (0 if unknown).
  823. * - encoding: set by user.
  824. * - decoding: set by lavc.
  825. */
  826. float aspect_ratio;
  827. /**
  828. * the picture in the bitstream.
  829. * - encoding: set by lavc
  830. * - decoding: set by lavc
  831. */
  832. AVFrame *coded_frame;
  833. /**
  834. * debug.
  835. * - encoding: set by user.
  836. * - decoding: set by user.
  837. */
  838. int debug;
  839. #define FF_DEBUG_PICT_INFO 1
  840. #define FF_DEBUG_RC 2
  841. #define FF_DEBUG_BITSTREAM 4
  842. #define FF_DEBUG_MB_TYPE 8
  843. #define FF_DEBUG_QP 16
  844. #define FF_DEBUG_MV 32
  845. #define FF_DEBUG_VIS_MV 0x00000040
  846. #define FF_DEBUG_SKIP 0x00000080
  847. #define FF_DEBUG_STARTCODE 0x00000100
  848. #define FF_DEBUG_PTS 0x00000200
  849. #define FF_DEBUG_ER 0x00000400
  850. #define FF_DEBUG_MMCO 0x00000800
  851. /**
  852. * error.
  853. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  854. * - decoding: unused
  855. */
  856. uint64_t error[4];
  857. /**
  858. * minimum MB quantizer.
  859. * - encoding: set by user.
  860. * - decoding: unused
  861. */
  862. int mb_qmin;
  863. /**
  864. * maximum MB quantizer.
  865. * - encoding: set by user.
  866. * - decoding: unused
  867. */
  868. int mb_qmax;
  869. /**
  870. * motion estimation compare function.
  871. * - encoding: set by user.
  872. * - decoding: unused
  873. */
  874. int me_cmp;
  875. /**
  876. * subpixel motion estimation compare function.
  877. * - encoding: set by user.
  878. * - decoding: unused
  879. */
  880. int me_sub_cmp;
  881. /**
  882. * macroblock compare function (not supported yet).
  883. * - encoding: set by user.
  884. * - decoding: unused
  885. */
  886. int mb_cmp;
  887. #define FF_CMP_SAD 0
  888. #define FF_CMP_SSE 1
  889. #define FF_CMP_SATD 2
  890. #define FF_CMP_DCT 3
  891. #define FF_CMP_PSNR 4
  892. #define FF_CMP_BIT 5
  893. #define FF_CMP_RD 6
  894. #define FF_CMP_ZERO 7
  895. #define FF_CMP_CHROMA 256
  896. /**
  897. * ME diamond size & shape.
  898. * - encoding: set by user.
  899. * - decoding: unused
  900. */
  901. int dia_size;
  902. /**
  903. * amount of previous MV predictors (2a+1 x 2a+1 square).
  904. * - encoding: set by user.
  905. * - decoding: unused
  906. */
  907. int last_predictor_count;
  908. /**
  909. * pre pass for motion estimation.
  910. * - encoding: set by user.
  911. * - decoding: unused
  912. */
  913. int pre_me;
  914. /**
  915. * motion estimation pre pass compare function.
  916. * - encoding: set by user.
  917. * - decoding: unused
  918. */
  919. int me_pre_cmp;
  920. /**
  921. * ME pre pass diamond size & shape.
  922. * - encoding: set by user.
  923. * - decoding: unused
  924. */
  925. int pre_dia_size;
  926. /**
  927. * subpel ME quality.
  928. * - encoding: set by user.
  929. * - decoding: unused
  930. */
  931. int me_subpel_quality;
  932. /**
  933. * callback to negotiate the pixelFormat.
  934. * @param fmt is the list of formats which are supported by the codec,
  935. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  936. * the first is allways the native one
  937. * @return the choosen format
  938. * - encoding: unused
  939. * - decoding: set by user, if not set then the native format will always be choosen
  940. */
  941. enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
  942. /**
  943. * DTG active format information (additionnal aspect ratio
  944. * information only used in DVB MPEG2 transport streams). 0 if
  945. * not set.
  946. *
  947. * - encoding: unused.
  948. * - decoding: set by decoder
  949. */
  950. int dtg_active_format;
  951. #define FF_DTG_AFD_SAME 8
  952. #define FF_DTG_AFD_4_3 9
  953. #define FF_DTG_AFD_16_9 10
  954. #define FF_DTG_AFD_14_9 11
  955. #define FF_DTG_AFD_4_3_SP_14_9 13
  956. #define FF_DTG_AFD_16_9_SP_14_9 14
  957. #define FF_DTG_AFD_SP_4_3 15
  958. /**
  959. * Maximum motion estimation search range in subpel units.
  960. * if 0 then no limit
  961. *
  962. * - encoding: set by user.
  963. * - decoding: unused.
  964. */
  965. int me_range;
  966. /**
  967. * frame_rate_base.
  968. * for variable fps this is 1
  969. * - encoding: set by user.
  970. * - decoding: set by lavc.
  971. * @todo move this after frame_rate
  972. */
  973. int frame_rate_base;
  974. /**
  975. * intra quantizer bias.
  976. * - encoding: set by user.
  977. * - decoding: unused
  978. */
  979. int intra_quant_bias;
  980. #define FF_DEFAULT_QUANT_BIAS 999999
  981. /**
  982. * inter quantizer bias.
  983. * - encoding: set by user.
  984. * - decoding: unused
  985. */
  986. int inter_quant_bias;
  987. /**
  988. * color table ID.
  989. * - encoding: unused.
  990. * - decoding: which clrtable should be used for 8bit RGB images
  991. * table have to be stored somewhere FIXME
  992. */
  993. int color_table_id;
  994. /**
  995. * internal_buffer count.
  996. * Dont touch, used by lavc default_get_buffer()
  997. */
  998. int internal_buffer_count;
  999. /**
  1000. * internal_buffers.
  1001. * Dont touch, used by lavc default_get_buffer()
  1002. */
  1003. void *internal_buffer;
  1004. #define FF_QUALITY_SCALE 256
  1005. /**
  1006. * global quality for codecs which cannot change it per frame.
  1007. * this should be proportional to MPEG1/2/4 qscale.
  1008. * - encoding: set by user.
  1009. * - decoding: unused
  1010. */
  1011. int global_quality;
  1012. #define FF_CODER_TYPE_VLC 0
  1013. #define FF_CODER_TYPE_AC 1
  1014. /**
  1015. * coder type
  1016. * - encoding: set by user.
  1017. * - decoding: unused
  1018. */
  1019. int coder_type;
  1020. /**
  1021. * context model
  1022. * - encoding: set by user.
  1023. * - decoding: unused
  1024. */
  1025. int context_model;
  1026. /**
  1027. * slice flags
  1028. * - encoding: unused
  1029. * - decoding: set by user.
  1030. */
  1031. int slice_flags;
  1032. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1033. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1034. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1035. } AVCodecContext;
  1036. /**
  1037. * AVOption.
  1038. */
  1039. typedef struct AVOption {
  1040. /** options' name */
  1041. const char *name; /* if name is NULL, it indicates a link to next */
  1042. /** short English text help or const struct AVOption* subpointer */
  1043. const char *help; // const struct AVOption* sub;
  1044. /** offset to context structure where the parsed value should be stored */
  1045. int offset;
  1046. /** options' type */
  1047. int type;
  1048. #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
  1049. #define FF_OPT_TYPE_DOUBLE 2 ///< double
  1050. #define FF_OPT_TYPE_INT 3 ///< integer
  1051. #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
  1052. #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
  1053. //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
  1054. #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
  1055. #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
  1056. /** min value (min == max -> no limits) */
  1057. double min;
  1058. /** maximum value for double/int */
  1059. double max;
  1060. /** default boo [0,1]l/double/int value */
  1061. double defval;
  1062. /**
  1063. * default string value (with optional semicolon delimited extra option-list
  1064. * i.e. option1;option2;option3
  1065. * defval might select other then first argument as default
  1066. */
  1067. const char *defstr;
  1068. #define FF_OPT_MAX_DEPTH 10
  1069. } AVOption;
  1070. /**
  1071. * Parse option(s) and sets fields in passed structure
  1072. * @param strct structure where the parsed results will be written
  1073. * @param list list with AVOptions
  1074. * @param opts string with options for parsing
  1075. */
  1076. int avoption_parse(void* strct, const AVOption* list, const char* opts);
  1077. /**
  1078. * AVCodec.
  1079. */
  1080. typedef struct AVCodec {
  1081. const char *name;
  1082. enum CodecType type;
  1083. int id;
  1084. int priv_data_size;
  1085. int (*init)(AVCodecContext *);
  1086. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1087. int (*close)(AVCodecContext *);
  1088. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1089. uint8_t *buf, int buf_size);
  1090. int capabilities;
  1091. const AVOption *options;
  1092. struct AVCodec *next;
  1093. void (*flush)(AVCodecContext *);
  1094. } AVCodec;
  1095. /**
  1096. * four components are given, that's all.
  1097. * the last component is alpha
  1098. */
  1099. typedef struct AVPicture {
  1100. uint8_t *data[4];
  1101. int linesize[4]; ///< number of bytes per line
  1102. } AVPicture;
  1103. extern AVCodec ac3_encoder;
  1104. extern AVCodec mp2_encoder;
  1105. extern AVCodec mp3lame_encoder;
  1106. extern AVCodec oggvorbis_encoder;
  1107. extern AVCodec mpeg1video_encoder;
  1108. extern AVCodec h263_encoder;
  1109. extern AVCodec h263p_encoder;
  1110. extern AVCodec flv_encoder;
  1111. extern AVCodec rv10_encoder;
  1112. extern AVCodec mjpeg_encoder;
  1113. extern AVCodec ljpeg_encoder;
  1114. extern AVCodec mpeg4_encoder;
  1115. extern AVCodec msmpeg4v1_encoder;
  1116. extern AVCodec msmpeg4v2_encoder;
  1117. extern AVCodec msmpeg4v3_encoder;
  1118. extern AVCodec wmv1_encoder;
  1119. extern AVCodec wmv2_encoder;
  1120. extern AVCodec huffyuv_encoder;
  1121. extern AVCodec h264_encoder;
  1122. extern AVCodec asv1_encoder;
  1123. extern AVCodec vcr1_encoder;
  1124. extern AVCodec ffv1_encoder;
  1125. extern AVCodec h263_decoder;
  1126. extern AVCodec mpeg4_decoder;
  1127. extern AVCodec msmpeg4v1_decoder;
  1128. extern AVCodec msmpeg4v2_decoder;
  1129. extern AVCodec msmpeg4v3_decoder;
  1130. extern AVCodec wmv1_decoder;
  1131. extern AVCodec wmv2_decoder;
  1132. extern AVCodec mpeg_decoder;
  1133. extern AVCodec h263i_decoder;
  1134. extern AVCodec flv_decoder;
  1135. extern AVCodec rv10_decoder;
  1136. extern AVCodec svq1_decoder;
  1137. extern AVCodec svq3_decoder;
  1138. extern AVCodec dvvideo_decoder;
  1139. extern AVCodec dvaudio_decoder;
  1140. extern AVCodec wmav1_decoder;
  1141. extern AVCodec wmav2_decoder;
  1142. extern AVCodec mjpeg_decoder;
  1143. extern AVCodec mjpegb_decoder;
  1144. extern AVCodec mp2_decoder;
  1145. extern AVCodec mp3_decoder;
  1146. extern AVCodec mace3_decoder;
  1147. extern AVCodec mace6_decoder;
  1148. extern AVCodec huffyuv_decoder;
  1149. extern AVCodec oggvorbis_decoder;
  1150. extern AVCodec cyuv_decoder;
  1151. extern AVCodec h264_decoder;
  1152. extern AVCodec indeo3_decoder;
  1153. extern AVCodec vp3_decoder;
  1154. extern AVCodec amr_nb_decoder;
  1155. extern AVCodec amr_nb_encoder;
  1156. extern AVCodec aac_decoder;
  1157. extern AVCodec mpeg4aac_decoder;
  1158. extern AVCodec asv1_decoder;
  1159. extern AVCodec vcr1_decoder;
  1160. extern AVCodec ffv1_decoder;
  1161. extern AVCodec fourxm_decoder;
  1162. extern AVCodec ra_144_decoder;
  1163. extern AVCodec ra_288_decoder;
  1164. /* pcm codecs */
  1165. #define PCM_CODEC(id, name) \
  1166. extern AVCodec name ## _decoder; \
  1167. extern AVCodec name ## _encoder
  1168. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  1169. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  1170. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  1171. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  1172. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  1173. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  1174. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  1175. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  1176. /* adpcm codecs */
  1177. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  1178. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  1179. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  1180. PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
  1181. #undef PCM_CODEC
  1182. /* dummy raw video codec */
  1183. extern AVCodec rawvideo_encoder;
  1184. extern AVCodec rawvideo_decoder;
  1185. /* the following codecs use external GPL libs */
  1186. extern AVCodec ac3_decoder;
  1187. /* resample.c */
  1188. struct ReSampleContext;
  1189. typedef struct ReSampleContext ReSampleContext;
  1190. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  1191. int output_rate, int input_rate);
  1192. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  1193. void audio_resample_close(ReSampleContext *s);
  1194. /* YUV420 format is assumed ! */
  1195. struct ImgReSampleContext;
  1196. typedef struct ImgReSampleContext ImgReSampleContext;
  1197. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  1198. int input_width, int input_height);
  1199. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  1200. int iwidth, int iheight,
  1201. int topBand, int bottomBand,
  1202. int leftBand, int rightBand);
  1203. void img_resample(ImgReSampleContext *s,
  1204. AVPicture *output, AVPicture *input);
  1205. void img_resample_close(ImgReSampleContext *s);
  1206. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  1207. int pix_fmt, int width, int height);
  1208. int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
  1209. unsigned char *dest, int dest_size);
  1210. int avpicture_get_size(int pix_fmt, int width, int height);
  1211. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  1212. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  1213. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  1214. #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
  1215. #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
  1216. #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
  1217. #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
  1218. #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
  1219. #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
  1220. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  1221. int has_alpha);
  1222. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  1223. int has_alpha, int *loss_ptr);
  1224. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  1225. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  1226. int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
  1227. /* convert among pixel formats */
  1228. int img_convert(AVPicture *dst, int dst_pix_fmt,
  1229. AVPicture *src, int pix_fmt,
  1230. int width, int height);
  1231. /* deinterlace a picture */
  1232. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  1233. int pix_fmt, int width, int height);
  1234. /* external high level API */
  1235. extern AVCodec *first_avcodec;
  1236. /* returns LIBAVCODEC_VERSION_INT constant */
  1237. unsigned avcodec_version(void);
  1238. /* returns LIBAVCODEC_BUILD constant */
  1239. unsigned avcodec_build(void);
  1240. void avcodec_init(void);
  1241. void register_avcodec(AVCodec *format);
  1242. AVCodec *avcodec_find_encoder(enum CodecID id);
  1243. AVCodec *avcodec_find_encoder_by_name(const char *name);
  1244. AVCodec *avcodec_find_decoder(enum CodecID id);
  1245. AVCodec *avcodec_find_decoder_by_name(const char *name);
  1246. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  1247. void avcodec_get_context_defaults(AVCodecContext *s);
  1248. AVCodecContext *avcodec_alloc_context(void);
  1249. AVFrame *avcodec_alloc_frame(void);
  1250. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  1251. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  1252. void avcodec_default_free_buffers(AVCodecContext *s);
  1253. /**
  1254. * opens / inits the AVCodecContext.
  1255. * not thread save!
  1256. */
  1257. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  1258. int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  1259. int *frame_size_ptr,
  1260. uint8_t *buf, int buf_size);
  1261. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  1262. int *got_picture_ptr,
  1263. uint8_t *buf, int buf_size);
  1264. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  1265. int *data_size_ptr,
  1266. uint8_t *buf, int buf_size);
  1267. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1268. const short *samples);
  1269. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  1270. const AVFrame *pict);
  1271. int avcodec_close(AVCodecContext *avctx);
  1272. void avcodec_register_all(void);
  1273. void avcodec_flush_buffers(AVCodecContext *avctx);
  1274. /* misc usefull functions */
  1275. /**
  1276. * returns a single letter to describe the picture type
  1277. */
  1278. char av_get_pict_type_char(int pict_type);
  1279. /**
  1280. * reduce a fraction.
  1281. * this is usefull for framerate calculations
  1282. * @param max the maximum allowed for dst_nom & dst_den
  1283. * @return 1 if exact, 0 otherwise
  1284. */
  1285. int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
  1286. /**
  1287. * rescale a 64bit integer.
  1288. * a simple a*b/c isnt possible as it can overflow
  1289. */
  1290. int64_t av_rescale(int64_t a, int b, int c);
  1291. /**
  1292. * Interface for 0.5.0 version
  1293. *
  1294. * do not even think about it's usage for this moment
  1295. */
  1296. typedef struct {
  1297. /// compressed size used from given memory buffer
  1298. int size;
  1299. /// I/P/B frame type
  1300. int frame_type;
  1301. } avc_enc_result_t;
  1302. /**
  1303. * Commands
  1304. * order can't be changed - once it was defined
  1305. */
  1306. typedef enum {
  1307. // general commands
  1308. AVC_OPEN_BY_NAME = 0xACA000,
  1309. AVC_OPEN_BY_CODEC_ID,
  1310. AVC_OPEN_BY_FOURCC,
  1311. AVC_CLOSE,
  1312. AVC_FLUSH,
  1313. // pin - struct { uint8_t* src, uint_t src_size }
  1314. // pout - struct { AVPicture* img, consumed_bytes,
  1315. AVC_DECODE,
  1316. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  1317. // pout - uint_t used_from_dest_size
  1318. AVC_ENCODE,
  1319. // query/get video commands
  1320. AVC_GET_VERSION = 0xACB000,
  1321. AVC_GET_WIDTH,
  1322. AVC_GET_HEIGHT,
  1323. AVC_GET_DELAY,
  1324. AVC_GET_QUANT_TABLE,
  1325. // ...
  1326. // query/get audio commands
  1327. AVC_GET_FRAME_SIZE = 0xABC000,
  1328. // maybe define some simple structure which
  1329. // might be passed to the user - but they can't
  1330. // contain any codec specific parts and these
  1331. // calls are usualy necessary only few times
  1332. // set video commands
  1333. AVC_SET_WIDTH = 0xACD000,
  1334. AVC_SET_HEIGHT,
  1335. // set video encoding commands
  1336. AVC_SET_FRAME_RATE = 0xACD800,
  1337. AVC_SET_QUALITY,
  1338. AVC_SET_HURRY_UP,
  1339. // set audio commands
  1340. AVC_SET_SAMPLE_RATE = 0xACE000,
  1341. AVC_SET_CHANNELS,
  1342. } avc_cmd_t;
  1343. /**
  1344. * \param handle allocated private structure by libavcodec
  1345. * for initialization pass NULL - will be returned pout
  1346. * user is supposed to know nothing about its structure
  1347. * \param cmd type of operation to be performed
  1348. * \param pint input parameter
  1349. * \param pout output parameter
  1350. *
  1351. * \returns command status - eventually for query command it might return
  1352. * integer resulting value
  1353. */
  1354. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  1355. /* memory */
  1356. void *av_malloc(unsigned int size);
  1357. void *av_mallocz(unsigned int size);
  1358. void *av_realloc(void *ptr, unsigned int size);
  1359. void av_free(void *ptr);
  1360. char *av_strdup(const char *s);
  1361. void __av_freep(void **ptr);
  1362. #define av_freep(p) __av_freep((void **)(p))
  1363. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  1364. /* for static data only */
  1365. /* call av_free_static to release all staticaly allocated tables */
  1366. void av_free_static(void);
  1367. void *__av_mallocz_static(void** location, unsigned int size);
  1368. #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
  1369. #ifdef __cplusplus
  1370. }
  1371. #endif
  1372. #endif /* AVCODEC_H */