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.

1127 lines
31KB

  1. #ifndef AVCODEC_H
  2. #define AVCODEC_H
  3. #include "common.h"
  4. #define LIBAVCODEC_VERSION_INT 0x000406
  5. #define LIBAVCODEC_VERSION "0.4.6"
  6. #define LIBAVCODEC_BUILD 4646
  7. #define LIBAVCODEC_BUILD_STR "4646"
  8. enum CodecID {
  9. CODEC_ID_NONE,
  10. CODEC_ID_MPEG1VIDEO,
  11. CODEC_ID_H263,
  12. CODEC_ID_RV10,
  13. CODEC_ID_MP2,
  14. CODEC_ID_MP3LAME,
  15. CODEC_ID_VORBIS,
  16. CODEC_ID_AC3,
  17. CODEC_ID_MJPEG,
  18. CODEC_ID_MJPEGB,
  19. CODEC_ID_MPEG4,
  20. CODEC_ID_RAWVIDEO,
  21. CODEC_ID_MSMPEG4V1,
  22. CODEC_ID_MSMPEG4V2,
  23. CODEC_ID_MSMPEG4V3,
  24. CODEC_ID_WMV1,
  25. CODEC_ID_WMV2,
  26. CODEC_ID_H263P,
  27. CODEC_ID_H263I,
  28. CODEC_ID_SVQ1,
  29. CODEC_ID_DVVIDEO,
  30. CODEC_ID_DVAUDIO,
  31. CODEC_ID_WMAV1,
  32. CODEC_ID_WMAV2,
  33. CODEC_ID_MACE3,
  34. CODEC_ID_MACE6,
  35. CODEC_ID_HUFFYUV,
  36. /* various pcm "codecs" */
  37. CODEC_ID_PCM_S16LE,
  38. CODEC_ID_PCM_S16BE,
  39. CODEC_ID_PCM_U16LE,
  40. CODEC_ID_PCM_U16BE,
  41. CODEC_ID_PCM_S8,
  42. CODEC_ID_PCM_U8,
  43. CODEC_ID_PCM_MULAW,
  44. CODEC_ID_PCM_ALAW,
  45. /* various adpcm codecs */
  46. CODEC_ID_ADPCM_IMA_QT,
  47. CODEC_ID_ADPCM_IMA_WAV,
  48. CODEC_ID_ADPCM_MS,
  49. };
  50. enum CodecType {
  51. CODEC_TYPE_UNKNOWN = -1,
  52. CODEC_TYPE_VIDEO,
  53. CODEC_TYPE_AUDIO,
  54. };
  55. enum PixelFormat {
  56. PIX_FMT_ANY = -1,
  57. PIX_FMT_YUV420P,
  58. PIX_FMT_YUV422,
  59. PIX_FMT_RGB24,
  60. PIX_FMT_BGR24,
  61. PIX_FMT_YUV422P,
  62. PIX_FMT_YUV444P,
  63. PIX_FMT_RGBA32,
  64. PIX_FMT_BGRA32,
  65. PIX_FMT_YUV410P,
  66. PIX_FMT_YUV411P,
  67. PIX_FMT_RGB565,
  68. PIX_FMT_RGB555,
  69. // PIX_FMT_RGB5551,
  70. PIX_FMT_BGR565,
  71. PIX_FMT_BGR555,
  72. // PIX_FMT_GBR565,
  73. // PIX_FMT_GBR555
  74. };
  75. /* currently unused, may be used if 24/32 bits samples ever supported */
  76. enum SampleFormat {
  77. SAMPLE_FMT_S16 = 0, /* signed 16 bits */
  78. };
  79. /* in bytes */
  80. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
  81. /**
  82. * Required number of zero bytes at the end of the input bitstream for decoding.
  83. * to avoid overreading (and possibly segfaulting)
  84. */
  85. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  86. /* motion estimation type, EPZS by default */
  87. enum Motion_Est_ID {
  88. ME_ZERO = 1,
  89. ME_FULL,
  90. ME_LOG,
  91. ME_PHODS,
  92. ME_EPZS,
  93. ME_X1
  94. };
  95. typedef struct RcOverride{
  96. int start_frame;
  97. int end_frame;
  98. int qscale; // if this is 0 then quality_factor will be used instead
  99. float quality_factor;
  100. } RcOverride;
  101. /* only for ME compatiblity with old apps */
  102. extern int motion_estimation_method;
  103. /* ME algos sorted by quality */
  104. static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
  105. ME_X1, ME_EPZS, ME_FULL };
  106. #define FF_MAX_B_FRAMES 8
  107. /* encoding support
  108. these flags can be passed in AVCodecContext.flags before initing
  109. Note: note not everything is supported yet
  110. */
  111. #define CODEC_FLAG_HQ 0x0001 /* brute force MB-type decission mode (slow) */
  112. #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
  113. #define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */
  114. #define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */
  115. #define CODEC_FLAG_GMC 0x0020 /* use GMC */
  116. #define CODEC_FLAG_PART 0x0080 /* use data partitioning */
  117. /* parent program gurantees that the input for b-frame containing streams is not written to
  118. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  119. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  120. #define CODEC_FLAG_PASS1 0x0200 /* use internal 2pass ratecontrol in first pass mode */
  121. #define CODEC_FLAG_PASS2 0x0400 /* use internal 2pass ratecontrol in second pass mode */
  122. #define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */
  123. #define CODEC_FLAG_GRAY 0x2000 /* only decode/encode grayscale */
  124. #define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */
  125. #define CODEC_FLAG_PSNR 0x8000 /* error[?] variables will be set during encoding */
  126. #define CODEC_FLAG_TRUNCATED 0x00010000 /* input bitstream might be truncated at a random location instead
  127. of only at frame boundaries */
  128. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 /* normalize adaptive quantization */
  129. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */
  130. #define CODEC_FLAG_LOW_DELAY 0x00080000 /* force low delay / will fail on b frames */
  131. #define CODEC_FLAG_ALT_SCAN 0x00100000 /* use alternate scan */
  132. /* codec capabilities */
  133. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 /* decoder can use draw_horiz_band callback */
  134. #define CODEC_CAP_DR1 0x0002 /* direct rendering method 1 */
  135. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  136. used */
  137. #define CODEC_CAP_PARSE_ONLY 0x0004
  138. #define CODEC_CAP_TRUNCATED 0x0008
  139. #define FRAME_RATE_BASE 10000
  140. #define FF_COMMON_FRAME \
  141. uint8_t *data[4];\
  142. int linesize[4];\
  143. /**\
  144. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  145. * this isnt used by lavc unless the default get/release_buffer() is used\
  146. * encoding: \
  147. * decoding: \
  148. */\
  149. uint8_t *base[4];\
  150. /**\
  151. * 1 -> keyframe, 0-> not\
  152. * encoding: set by lavc\
  153. * decoding: set by lavc\
  154. */\
  155. int key_frame;\
  156. \
  157. /**\
  158. * picture type of the frame, see ?_TYPE below\
  159. * encoding: set by lavc for coded_picture (and set by user for input)\
  160. * decoding: set by lavc\
  161. */\
  162. int pict_type;\
  163. \
  164. /**\
  165. * presentation timestamp in micro seconds (time when frame should be shown to user)\
  166. * if 0 then the frame_rate will be used as reference\
  167. * encoding: MUST be set by user\
  168. * decoding: set by lavc\
  169. */\
  170. long long int pts;\
  171. \
  172. /**\
  173. * picture number in bitstream order.\
  174. * encoding: set by\
  175. * decoding: set by lavc\
  176. */\
  177. int coded_picture_number;\
  178. /**\
  179. * encoding: set by\
  180. * decoding: set by lavc\
  181. * picture number in display order.\
  182. */\
  183. int display_picture_number;\
  184. \
  185. /**\
  186. * quality (between 1 (good) and 31 (bad)) \
  187. * encoding: set by lavc for coded_picture (and set by user for input)\
  188. * decoding: set by lavc\
  189. */\
  190. float quality; \
  191. \
  192. /**\
  193. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  194. * set to something large if the buffer has not been used yet \
  195. * encoding: unused\
  196. * decoding: MUST be set by get_buffer()\
  197. */\
  198. int age;\
  199. \
  200. /**\
  201. * is this picture used as reference\
  202. * encoding: unused\
  203. * decoding: set by lavc (before get_buffer() call))\
  204. */\
  205. int reference;\
  206. \
  207. /**\
  208. * QP table\
  209. * encoding: unused\
  210. * decoding: set by lavc\
  211. */\
  212. int8_t *qscale_table;\
  213. /**\
  214. * QP store stride\
  215. * encoding: unused\
  216. * decoding: set by lavc\
  217. */\
  218. int qstride;\
  219. \
  220. /**\
  221. * mbskip_table[mb]>=1 if MB didnt change\
  222. * stride= mb_width = (width+15)>>4\
  223. * encoding: unused\
  224. * decoding: set by lavc\
  225. */\
  226. uint8_t *mbskip_table;\
  227. \
  228. /**\
  229. * for some private data of the user\
  230. * encoding: unused\
  231. * decoding: set by user\
  232. */\
  233. void *opaque;\
  234. \
  235. /**\
  236. * error\
  237. * encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  238. * decoding: unused\
  239. */\
  240. uint64_t error[4];\
  241. \
  242. /**\
  243. * type of the buffer (to keep track of who has to dealloc data[*])\
  244. * encoding: set by the one who allocs it\
  245. * decoding: set by the one who allocs it\
  246. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  247. */\
  248. int type;\
  249. #define FF_BUFFER_TYPE_INTERNAL 1
  250. #define FF_BUFFER_TYPE_USER 2 // Direct rendering buffers
  251. #define FF_BUFFER_TYPE_SHARED 4 // input frame for encoding(wont be dealloced)
  252. #define FF_I_TYPE 1 // Intra
  253. #define FF_P_TYPE 2 // Predicted
  254. #define FF_B_TYPE 3 // Bi-dir predicted
  255. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  256. typedef struct AVFrame {
  257. FF_COMMON_FRAME
  258. } AVFrame;
  259. typedef struct AVCodecContext {
  260. /**
  261. * the average bitrate
  262. * encoding: set by user. unused for constant quantizer encoding
  263. * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  264. */
  265. int bit_rate;
  266. /**
  267. * number of bits the bitstream is allowed to diverge from the reference
  268. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  269. * encoding: set by user. unused for constant quantizer encoding
  270. * decoding: unused
  271. */
  272. int bit_rate_tolerance;
  273. /**
  274. * CODEC_FLAG_*
  275. * encoding: set by user.
  276. * decoding: set by user.
  277. */
  278. int flags;
  279. /**
  280. * some codecs needs additionnal format info. It is stored here
  281. * encoding: set by user.
  282. * decoding: set by lavc. (FIXME is this ok?)
  283. */
  284. int sub_id;
  285. /**
  286. * motion estimation algorithm used for video coding
  287. * encoding: MUST be set by user.
  288. * decoding: unused
  289. */
  290. int me_method;
  291. /**
  292. * some codecs need / can use extra-data like huffman tables
  293. * mjpeg: huffman tables
  294. * rv10: additional flags
  295. * mpeg4: global headers (they can be in the bitstream or here)
  296. * encoding: set/allocated/freed by lavc.
  297. * decoding: set/allocated/freed by user.
  298. */
  299. void *extradata;
  300. int extradata_size;
  301. /* video only */
  302. /**
  303. * frames per sec multiplied by FRAME_RATE_BASE
  304. * for variable fps this is the precission, so if the timestamps
  305. * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
  306. * encoding: MUST be set by user
  307. * decoding: set by lavc. 0 or the frame_rate if available
  308. */
  309. int frame_rate;
  310. /**
  311. * encoding: MUST be set by user.
  312. * decoding: set by user, some codecs might override / change it during playback
  313. */
  314. int width, height;
  315. #define FF_ASPECT_SQUARE 1
  316. #define FF_ASPECT_4_3_625 2
  317. #define FF_ASPECT_4_3_525 3
  318. #define FF_ASPECT_16_9_625 4
  319. #define FF_ASPECT_16_9_525 5
  320. #define FF_ASPECT_EXTENDED 15
  321. /**
  322. * the number of pictures in a group of pitures, or 0 for intra_only
  323. * encoding: set by user.
  324. * decoding: unused
  325. */
  326. int gop_size;
  327. /**
  328. * pixel format, see PIX_FMT_xxx
  329. * encoding: unused
  330. * decoding: set by lavc.
  331. */
  332. enum PixelFormat pix_fmt;
  333. int repeat_pict; /* when decoding, this signal how much the picture */
  334. /* must be delayed. */
  335. /* extra_delay = (repeat_pict / 2) * (1/fps) */
  336. /**
  337. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  338. * decoder to draw an horizontal band. It improve cache usage. Not
  339. * all codecs can do that. You must check the codec capabilities
  340. * before
  341. * encoding: unused
  342. * decoding: set by user.
  343. */
  344. void (*draw_horiz_band)(struct AVCodecContext *s,
  345. UINT8 **src_ptr, int linesize,
  346. int y, int width, int height);
  347. /* audio only */
  348. int sample_rate; /* samples per sec */
  349. int channels;
  350. int sample_fmt; /* sample format, currenly unused */
  351. /* the following data should not be initialized */
  352. int frame_size; /* in samples, initialized when calling 'init' */
  353. int frame_number; /* audio or video frame number */
  354. int real_pict_num; /* returns the real picture number of
  355. previous encoded frame */
  356. /**
  357. * number of frames the decoded output will be delayed relative to
  358. * the encoded input
  359. * encoding: set by lavc.
  360. * decoding: unused
  361. */
  362. int delay;
  363. /* encoding parameters */
  364. float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
  365. float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
  366. /**
  367. * minimum quantizer
  368. * encoding: set by user.
  369. * decoding: unused
  370. */
  371. int qmin;
  372. /**
  373. * maximum quantizer
  374. * encoding: set by user.
  375. * decoding: unused
  376. */
  377. int qmax;
  378. /**
  379. * maximum quantizer difference etween frames
  380. * encoding: set by user.
  381. * decoding: unused
  382. */
  383. int max_qdiff;
  384. /**
  385. * maximum number of b frames between non b frames
  386. * note: the output will be delayed by max_b_frames+1 relative to the input
  387. * encoding: set by user.
  388. * decoding: unused
  389. */
  390. int max_b_frames;
  391. /**
  392. * qscale factor between ip and b frames
  393. * encoding: set by user.
  394. * decoding: unused
  395. */
  396. float b_quant_factor;
  397. /** obsolete FIXME remove */
  398. int rc_strategy;
  399. int b_frame_strategy;
  400. /**
  401. * encoding: unused
  402. * decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  403. */
  404. int hurry_up;
  405. struct AVCodec *codec;
  406. void *priv_data;
  407. /* The following data is for RTP friendly coding */
  408. /* By now only H.263/H.263+/MPEG4 coder honours this */
  409. int rtp_mode; /* 1 for activate RTP friendly-mode */
  410. /* highers numbers represent more error-prone */
  411. /* enviroments, by now just "1" exist */
  412. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  413. /* do it's best to deliver a chunk with size */
  414. /* below rtp_payload_size, the chunk will start */
  415. /* with a start code on some codecs like H.263 */
  416. /* This doesn't take account of any particular */
  417. /* headers inside the transmited RTP payload */
  418. /* The RTP callcack: This function is called */
  419. /* every time the encoder as a packet to send */
  420. /* Depends on the encoder if the data starts */
  421. /* with a Start Code (it should) H.263 does */
  422. void (*rtp_callback)(void *data, int size, int packet_number);
  423. /* statistics, used for 2-pass encoding */
  424. int mv_bits;
  425. int header_bits;
  426. int i_tex_bits;
  427. int p_tex_bits;
  428. int i_count;
  429. int p_count;
  430. int skip_count;
  431. int misc_bits;
  432. /**
  433. * number of bits used for the previously encoded frame
  434. * encoding: set by lavc
  435. * decoding: - for audio - bits_per_sample
  436. */
  437. int frame_bits;
  438. /**
  439. * private data of the user, can be used to carry app specific stuff
  440. * encoding: set by user
  441. * decoding: set by user
  442. */
  443. void *opaque;
  444. char codec_name[32];
  445. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  446. enum CodecID codec_id; /* see CODEC_ID_xxx */
  447. unsigned int codec_tag; /* codec tag, only used if unknown codec */
  448. /**
  449. * workaround bugs in encoders which sometimes cannot be detected automatically
  450. * encoding: unused
  451. * decoding: set by user
  452. */
  453. int workaround_bugs;
  454. #define FF_BUG_AUTODETECT 1 //autodetection
  455. #define FF_BUG_OLD_MSMPEG4 2
  456. #define FF_BUG_XVID_ILACE 4
  457. #define FF_BUG_UMP4 8
  458. #define FF_BUG_NO_PADDING 16
  459. #define FF_BUG_AC_VLC 32
  460. #define FF_BUG_QPEL_CHROMA 64
  461. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  462. /**
  463. * encoding: set by user
  464. * decoding: unused
  465. */
  466. int luma_elim_threshold;
  467. /**
  468. * encoding: set by user
  469. * decoding: unused
  470. */
  471. int chroma_elim_threshold;
  472. /**
  473. * strictly follow the std (MPEG4, ...)
  474. * encoding: set by user
  475. * decoding: unused
  476. */
  477. int strict_std_compliance;
  478. /**
  479. * qscale offset between ip and b frames
  480. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  481. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  482. * encoding: set by user.
  483. * decoding: unused
  484. */
  485. float b_quant_offset;
  486. /**
  487. * error resilience higher values will detect more errors but may missdetect
  488. * some more or less valid parts as errors
  489. * encoding: unused
  490. * decoding: set by user
  491. */
  492. int error_resilience;
  493. #define FF_ER_CAREFULL 1
  494. #define FF_ER_COMPLIANT 2
  495. #define FF_ER_AGGRESSIVE 3
  496. #define FF_ER_VERY_AGGRESSIVE 4
  497. /**
  498. * called at the beginning of each frame to get a buffer for it.
  499. * if pic.reference is set then the frame will be read later by lavc
  500. * encoding: unused
  501. * decoding: set by lavc, user can override
  502. */
  503. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  504. /**
  505. * called to release buffers which where allocated with get_buffer.
  506. * a released buffer can be reused in get_buffer()
  507. * pic.data[*] must be set to NULL
  508. * encoding: unused
  509. * decoding: set by lavc, user can override
  510. */
  511. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  512. /**
  513. * is 1 if the decoded stream contains b frames, 0 otherwise
  514. * encoding: unused
  515. * decoding: set by lavc
  516. */
  517. int has_b_frames;
  518. int block_align; /* used by some WAV based audio codecs */
  519. int parse_only; /* decoding only: if true, only parsing is done
  520. (function avcodec_parse_frame()). The frame
  521. data is returned. Only MPEG codecs support this now. */
  522. /**
  523. * 0-> h263 quant 1-> mpeg quant
  524. * encoding: set by user.
  525. * decoding: unused
  526. */
  527. int mpeg_quant;
  528. /**
  529. * pass1 encoding statistics output buffer
  530. * encoding: set by lavc
  531. * decoding: unused
  532. */
  533. char *stats_out; /* encoding statistics output buffer */
  534. /**
  535. * pass2 encoding statistics input buffer.
  536. * concatenated stuff from stats_out of pass1 should be placed here
  537. * encoding: allocated/set/freed by user
  538. * decoding: unused
  539. */
  540. char *stats_in;
  541. /**
  542. * ratecontrol qmin qmax limiting method
  543. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  544. * encoding: set by user.
  545. * decoding: unused
  546. */
  547. float rc_qsquish;
  548. float rc_qmod_amp;
  549. int rc_qmod_freq;
  550. /**
  551. * ratecontrol override, see RcOverride
  552. * encoding: allocated/set/freed by user.
  553. * decoding: unused
  554. */
  555. RcOverride *rc_override;
  556. int rc_override_count;
  557. /**
  558. * rate control equation
  559. * encoding: set by user
  560. * decoding: unused
  561. */
  562. char *rc_eq;
  563. /**
  564. * maximum bitrate
  565. * encoding: set by user.
  566. * decoding: unused
  567. */
  568. int rc_max_rate;
  569. /**
  570. * minimum bitrate
  571. * encoding: set by user.
  572. * decoding: unused
  573. */
  574. int rc_min_rate;
  575. /**
  576. * decoder bitstream buffer size
  577. * encoding: set by user.
  578. * decoding: unused
  579. */
  580. int rc_buffer_size;
  581. float rc_buffer_aggressivity;
  582. /**
  583. * qscale factor between p and i frames
  584. * encoding: set by user.
  585. * decoding: unused
  586. */
  587. float i_quant_factor;
  588. /**
  589. * qscale offset between p and i frames
  590. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  591. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  592. * encoding: set by user.
  593. * decoding: unused
  594. */
  595. float i_quant_offset;
  596. /**
  597. * initial complexity for pass1 ratecontrol
  598. * encoding: set by user.
  599. * decoding: unused
  600. */
  601. float rc_initial_cplx;
  602. /**
  603. * dct algorithm, see FF_DCT_* below
  604. * encoding: set by user
  605. * decoding: unused
  606. */
  607. int dct_algo;
  608. #define FF_DCT_AUTO 0
  609. #define FF_DCT_FASTINT 1
  610. #define FF_DCT_INT 2
  611. #define FF_DCT_MMX 3
  612. #define FF_DCT_MLIB 4
  613. #define FF_DCT_ALTIVEC 5
  614. /**
  615. * luminance masking (0-> disabled)
  616. * encoding: set by user
  617. * decoding: unused
  618. */
  619. float lumi_masking;
  620. /**
  621. * temporary complexity masking (0-> disabled)
  622. * encoding: set by user
  623. * decoding: unused
  624. */
  625. float temporal_cplx_masking;
  626. /**
  627. * spatial complexity masking (0-> disabled)
  628. * encoding: set by user
  629. * decoding: unused
  630. */
  631. float spatial_cplx_masking;
  632. /**
  633. * p block masking (0-> disabled)
  634. * encoding: set by user
  635. * decoding: unused
  636. */
  637. float p_masking;
  638. /**
  639. * darkness masking (0-> disabled)
  640. * encoding: set by user
  641. * decoding: unused
  642. */
  643. float dark_masking;
  644. /**
  645. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
  646. * this is used to workaround some encoder bugs
  647. * encoding: unused
  648. * decoding: set by user, will be converted to upper case by lavc during init
  649. */
  650. int fourcc;
  651. /**
  652. * idct algorithm, see FF_IDCT_* below
  653. * encoding: set by user
  654. * decoding: set by user
  655. */
  656. int idct_algo;
  657. #define FF_IDCT_AUTO 0
  658. #define FF_IDCT_INT 1
  659. #define FF_IDCT_SIMPLE 2
  660. #define FF_IDCT_SIMPLEMMX 3
  661. #define FF_IDCT_LIBMPEG2MMX 4
  662. #define FF_IDCT_PS2 5
  663. #define FF_IDCT_MLIB 6
  664. #define FF_IDCT_ARM 7
  665. #define FF_IDCT_ALTIVEC 8
  666. /**
  667. * slice count
  668. * encoding: set by lavc
  669. * decoding: set by user (or 0)
  670. */
  671. int slice_count;
  672. /**
  673. * slice offsets in the frame in bytes
  674. * encoding: set/allocated by lavc
  675. * decoding: set/allocated by user (or NULL)
  676. */
  677. int *slice_offset;
  678. /**
  679. * error concealment flags
  680. * encoding: unused
  681. * decoding: set by user
  682. */
  683. int error_concealment;
  684. #define FF_EC_GUESS_MVS 1
  685. #define FF_EC_DEBLOCK 2
  686. /**
  687. * dsp_mask could be used to disable unwanted
  688. * CPU features (i.e. MMX, SSE. ...)
  689. */
  690. unsigned dsp_mask;
  691. /**
  692. * bits per sample/pixel from the demuxer (needed for huffyuv)
  693. * encoding: set by lavc
  694. * decoding: set by user
  695. */
  696. int bits_per_sample;
  697. /**
  698. * prediction method (needed for huffyuv)
  699. * encoding: set by user
  700. * decoding: unused
  701. */
  702. int prediction_method;
  703. #define FF_PRED_LEFT 0
  704. #define FF_PRED_PLANE 1
  705. #define FF_PRED_MEDIAN 2
  706. /**
  707. * aspect ratio. (0 if unknown)
  708. * encoding: set by user.
  709. * decoding: set by lavc.
  710. */
  711. float aspect_ratio;
  712. /**
  713. * the picture in the bitstream
  714. * encoding: set by lavc
  715. * decoding: set by lavc
  716. */
  717. AVFrame *coded_frame;
  718. /**
  719. * debug
  720. * encoding: set by user.
  721. * decoding: set by user.
  722. */
  723. int debug;
  724. #define FF_DEBUG_PICT_INFO 1
  725. #define FF_DEBUG_RC 2
  726. #define FF_DEBUG_BITSTREAM 4
  727. #define FF_DEBUG_MB_TYPE 8
  728. #define FF_DEBUG_QP 16
  729. #define FF_DEBUG_MV 32
  730. #define FF_DEBUG_VIS_MV 64
  731. #define FF_DEBUG_SKIP 128
  732. /**
  733. * error
  734. * encoding: set by lavc if flags&CODEC_FLAG_PSNR
  735. * decoding: unused
  736. */
  737. uint64_t error[4];
  738. /**
  739. * minimum MB quantizer
  740. * encoding: set by user.
  741. * decoding: unused
  742. */
  743. int mb_qmin;
  744. /**
  745. * maximum MB quantizer
  746. * encoding: set by user.
  747. * decoding: unused
  748. */
  749. int mb_qmax;
  750. } AVCodecContext;
  751. typedef struct AVCodec {
  752. const char *name;
  753. int type;
  754. int id;
  755. int priv_data_size;
  756. int (*init)(AVCodecContext *);
  757. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  758. int (*close)(AVCodecContext *);
  759. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  760. UINT8 *buf, int buf_size);
  761. int capabilities;
  762. struct AVCodec *next;
  763. } AVCodec;
  764. /**
  765. * four components are given, that's all.
  766. * the last component is alpha
  767. */
  768. typedef struct AVPicture {
  769. UINT8 *data[4];
  770. int linesize[4];
  771. } AVPicture;
  772. extern AVCodec ac3_encoder;
  773. extern AVCodec mp2_encoder;
  774. extern AVCodec mp3lame_encoder;
  775. extern AVCodec oggvorbis_encoder;
  776. extern AVCodec mpeg1video_encoder;
  777. extern AVCodec h263_encoder;
  778. extern AVCodec h263p_encoder;
  779. extern AVCodec rv10_encoder;
  780. extern AVCodec mjpeg_encoder;
  781. extern AVCodec mpeg4_encoder;
  782. extern AVCodec msmpeg4v1_encoder;
  783. extern AVCodec msmpeg4v2_encoder;
  784. extern AVCodec msmpeg4v3_encoder;
  785. extern AVCodec wmv1_encoder;
  786. extern AVCodec wmv2_encoder;
  787. extern AVCodec huffyuv_encoder;
  788. extern AVCodec h263_decoder;
  789. extern AVCodec mpeg4_decoder;
  790. extern AVCodec msmpeg4v1_decoder;
  791. extern AVCodec msmpeg4v2_decoder;
  792. extern AVCodec msmpeg4v3_decoder;
  793. extern AVCodec wmv1_decoder;
  794. extern AVCodec wmv2_decoder;
  795. extern AVCodec mpeg_decoder;
  796. extern AVCodec h263i_decoder;
  797. extern AVCodec rv10_decoder;
  798. extern AVCodec svq1_decoder;
  799. extern AVCodec dvvideo_decoder;
  800. extern AVCodec dvaudio_decoder;
  801. extern AVCodec wmav1_decoder;
  802. extern AVCodec wmav2_decoder;
  803. extern AVCodec mjpeg_decoder;
  804. extern AVCodec mjpegb_decoder;
  805. extern AVCodec mp2_decoder;
  806. extern AVCodec mp3_decoder;
  807. extern AVCodec mace3_decoder;
  808. extern AVCodec mace6_decoder;
  809. extern AVCodec huffyuv_decoder;
  810. extern AVCodec oggvorbis_decoder;
  811. /* pcm codecs */
  812. #define PCM_CODEC(id, name) \
  813. extern AVCodec name ## _decoder; \
  814. extern AVCodec name ## _encoder
  815. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  816. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  817. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  818. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  819. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  820. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  821. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  822. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  823. /* adpcm codecs */
  824. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  825. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  826. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  827. #undef PCM_CODEC
  828. /* dummy raw video codec */
  829. extern AVCodec rawvideo_codec;
  830. /* the following codecs use external GPL libs */
  831. extern AVCodec ac3_decoder;
  832. /* resample.c */
  833. struct ReSampleContext;
  834. typedef struct ReSampleContext ReSampleContext;
  835. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  836. int output_rate, int input_rate);
  837. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  838. void audio_resample_close(ReSampleContext *s);
  839. /* YUV420 format is assumed ! */
  840. struct ImgReSampleContext;
  841. typedef struct ImgReSampleContext ImgReSampleContext;
  842. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  843. int input_width, int input_height);
  844. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  845. int iwidth, int iheight,
  846. int topBand, int bottomBand,
  847. int leftBand, int rightBand);
  848. void img_resample(ImgReSampleContext *s,
  849. AVPicture *output, AVPicture *input);
  850. void img_resample_close(ImgReSampleContext *s);
  851. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  852. int pix_fmt, int width, int height);
  853. int avpicture_get_size(int pix_fmt, int width, int height);
  854. void avcodec_get_chroma_sub_sample(int fmt, int *h_shift, int *v_shift);
  855. /* convert among pixel formats */
  856. int img_convert(AVPicture *dst, int dst_pix_fmt,
  857. AVPicture *src, int pix_fmt,
  858. int width, int height);
  859. /* deinterlace a picture */
  860. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  861. int pix_fmt, int width, int height);
  862. /* external high level API */
  863. extern AVCodec *first_avcodec;
  864. /* returns LIBAVCODEC_VERSION_INT constant */
  865. unsigned avcodec_version(void);
  866. /* returns LIBAVCODEC_BUILD constant */
  867. unsigned avcodec_build(void);
  868. void avcodec_init(void);
  869. void avcodec_set_bit_exact(void);
  870. void register_avcodec(AVCodec *format);
  871. AVCodec *avcodec_find_encoder(enum CodecID id);
  872. AVCodec *avcodec_find_encoder_by_name(const char *name);
  873. AVCodec *avcodec_find_decoder(enum CodecID id);
  874. AVCodec *avcodec_find_decoder_by_name(const char *name);
  875. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  876. void avcodec_get_context_defaults(AVCodecContext *s);
  877. AVCodecContext *avcodec_alloc_context(void);
  878. AVFrame *avcodec_alloc_frame(void);
  879. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  880. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  881. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  882. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  883. int *frame_size_ptr,
  884. UINT8 *buf, int buf_size);
  885. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  886. int *got_picture_ptr,
  887. UINT8 *buf, int buf_size);
  888. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  889. int *data_size_ptr,
  890. UINT8 *buf, int buf_size);
  891. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  892. const short *samples);
  893. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  894. const AVFrame *pict);
  895. int avcodec_close(AVCodecContext *avctx);
  896. void avcodec_register_all(void);
  897. void avcodec_flush_buffers(AVCodecContext *avctx);
  898. /**
  899. * Interface for 0.5.0 version
  900. *
  901. * do not even think about it's usage for this moment
  902. */
  903. typedef struct {
  904. // compressed size used from given memory buffer
  905. int size;
  906. /// I/P/B frame type
  907. int frame_type;
  908. } avc_enc_result_t;
  909. /**
  910. * Commands
  911. * order can't be changed - once it was defined
  912. */
  913. typedef enum {
  914. // general commands
  915. AVC_OPEN_BY_NAME = 0xACA000,
  916. AVC_OPEN_BY_CODEC_ID,
  917. AVC_OPEN_BY_FOURCC,
  918. AVC_CLOSE,
  919. AVC_FLUSH,
  920. // pin - struct { uint8_t* src, uint_t src_size }
  921. // pout - struct { AVPicture* img, consumed_bytes,
  922. AVC_DECODE,
  923. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  924. // pout - uint_t used_from_dest_size
  925. AVC_ENCODE,
  926. // query/get video commands
  927. AVC_GET_VERSION = 0xACB000,
  928. AVC_GET_WIDTH,
  929. AVC_GET_HEIGHT,
  930. AVC_GET_DELAY,
  931. AVC_GET_QUANT_TABLE,
  932. // ...
  933. // query/get audio commands
  934. AVC_GET_FRAME_SIZE = 0xABC000,
  935. // maybe define some simple structure which
  936. // might be passed to the user - but they can't
  937. // contain any codec specific parts and these
  938. // calls are usualy necessary only few times
  939. // set video commands
  940. AVC_SET_WIDTH = 0xACD000,
  941. AVC_SET_HEIGHT,
  942. // set video encoding commands
  943. AVC_SET_FRAME_RATE = 0xACD800,
  944. AVC_SET_QUALITY,
  945. AVC_SET_HURRY_UP,
  946. // set audio commands
  947. AVC_SET_SAMPLE_RATE = 0xACE000,
  948. AVC_SET_CHANNELS,
  949. } avc_cmd_t;
  950. /**
  951. * \param handle allocated private structure by libavcodec
  952. * for initialization pass NULL - will be returned pout
  953. * user is supposed to know nothing about its structure
  954. * \param cmd type of operation to be performed
  955. * \param pint input parameter
  956. * \param pout output parameter
  957. *
  958. * \returns command status - eventually for query command it might return
  959. * integer resulting value
  960. */
  961. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  962. /* memory */
  963. void *av_malloc(unsigned int size);
  964. void *av_mallocz(unsigned int size);
  965. void av_free(void *ptr);
  966. void __av_freep(void **ptr);
  967. #define av_freep(p) __av_freep((void **)(p))
  968. /* for static data only */
  969. /* call av_free_static to release all staticaly allocated tables */
  970. void av_free_static();
  971. void *__av_mallocz_static(void** location, unsigned int size);
  972. #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
  973. #endif /* AVCODEC_H */