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.

1106 lines
30KB

  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 4643
  7. #define LIBAVCODEC_BUILD_STR "4643"
  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 4
  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_PICTURE \
  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. #define FF_I_TYPE 1 // Intra
  242. #define FF_P_TYPE 2 // Predicted
  243. #define FF_B_TYPE 3 // Bi-dir predicted
  244. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  245. typedef struct AVVideoFrame {
  246. FF_COMMON_PICTURE
  247. } AVVideoFrame;
  248. typedef struct AVCodecContext {
  249. /**
  250. * the average bitrate
  251. * encoding: set by user. unused for constant quantizer encoding
  252. * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  253. */
  254. int bit_rate;
  255. /**
  256. * number of bits the bitstream is allowed to diverge from the reference
  257. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  258. * encoding: set by user. unused for constant quantizer encoding
  259. * decoding: unused
  260. */
  261. int bit_rate_tolerance;
  262. /**
  263. * CODEC_FLAG_*
  264. * encoding: set by user.
  265. * decoding: set by user.
  266. */
  267. int flags;
  268. /**
  269. * some codecs needs additionnal format info. It is stored here
  270. * encoding: set by user.
  271. * decoding: set by lavc. (FIXME is this ok?)
  272. */
  273. int sub_id;
  274. /**
  275. * motion estimation algorithm used for video coding
  276. * encoding: MUST be set by user.
  277. * decoding: unused
  278. */
  279. int me_method;
  280. /**
  281. * some codecs need / can use extra-data like huffman tables
  282. * mjpeg: huffman tables
  283. * rv10: additional flags
  284. * mpeg4: global headers (they can be in the bitstream or here)
  285. * encoding: set/allocated/freed by lavc.
  286. * decoding: set/allocated/freed by user.
  287. */
  288. void *extradata;
  289. int extradata_size;
  290. /* video only */
  291. /**
  292. * frames per sec multiplied by FRAME_RATE_BASE
  293. * for variable fps this is the precission, so if the timestamps
  294. * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
  295. * encoding: MUST be set by user
  296. * decoding: set by lavc. 0 or the frame_rate if available
  297. */
  298. int frame_rate;
  299. /**
  300. * encoding: MUST be set by user.
  301. * decoding: set by user, some codecs might override / change it during playback
  302. */
  303. int width, height;
  304. #define FF_ASPECT_SQUARE 1
  305. #define FF_ASPECT_4_3_625 2
  306. #define FF_ASPECT_4_3_525 3
  307. #define FF_ASPECT_16_9_625 4
  308. #define FF_ASPECT_16_9_525 5
  309. #define FF_ASPECT_EXTENDED 15
  310. /**
  311. * the number of pictures in a group of pitures, or 0 for intra_only
  312. * encoding: set by user.
  313. * decoding: unused
  314. */
  315. int gop_size;
  316. /**
  317. * pixel format, see PIX_FMT_xxx
  318. * encoding: unused
  319. * decoding: set by lavc.
  320. */
  321. enum PixelFormat pix_fmt;
  322. int repeat_pict; /* when decoding, this signal how much the picture */
  323. /* must be delayed. */
  324. /* extra_delay = (repeat_pict / 2) * (1/fps) */
  325. /**
  326. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  327. * decoder to draw an horizontal band. It improve cache usage. Not
  328. * all codecs can do that. You must check the codec capabilities
  329. * before
  330. * encoding: unused
  331. * decoding: set by user.
  332. */
  333. void (*draw_horiz_band)(struct AVCodecContext *s,
  334. UINT8 **src_ptr, int linesize,
  335. int y, int width, int height);
  336. /* audio only */
  337. int sample_rate; /* samples per sec */
  338. int channels;
  339. int sample_fmt; /* sample format, currenly unused */
  340. /* the following data should not be initialized */
  341. int frame_size; /* in samples, initialized when calling 'init' */
  342. int frame_number; /* audio or video frame number */
  343. int real_pict_num; /* returns the real picture number of
  344. previous encoded frame */
  345. /**
  346. * 1 -> keyframe, 0-> not (this if for audio only, for video, AVVideoFrame.key_frame should be used)
  347. * encoding: set by lavc (for the outputed bitstream, not the input frame)
  348. * decoding: set by lavc (for the decoded bitstream, not the displayed frame)
  349. */
  350. int key_frame;
  351. /**
  352. * number of frames the decoded output will be delayed relative to
  353. * the encoded input
  354. * encoding: set by lavc.
  355. * decoding: unused
  356. */
  357. int delay;
  358. /* encoding parameters */
  359. float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
  360. float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
  361. /**
  362. * minimum quantizer
  363. * encoding: set by user.
  364. * decoding: unused
  365. */
  366. int qmin;
  367. /**
  368. * maximum quantizer
  369. * encoding: set by user.
  370. * decoding: unused
  371. */
  372. int qmax;
  373. /**
  374. * maximum quantizer difference etween frames
  375. * encoding: set by user.
  376. * decoding: unused
  377. */
  378. int max_qdiff;
  379. /**
  380. * maximum number of b frames between non b frames
  381. * note: the output will be delayed by max_b_frames+1 relative to the input
  382. * encoding: set by user.
  383. * decoding: unused
  384. */
  385. int max_b_frames;
  386. /**
  387. * qscale factor between ip and b frames
  388. * encoding: set by user.
  389. * decoding: unused
  390. */
  391. float b_quant_factor;
  392. /** obsolete FIXME remove */
  393. int rc_strategy;
  394. int b_frame_strategy;
  395. /**
  396. * encoding: unused
  397. * decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  398. */
  399. int hurry_up;
  400. struct AVCodec *codec;
  401. void *priv_data;
  402. /* The following data is for RTP friendly coding */
  403. /* By now only H.263/H.263+/MPEG4 coder honours this */
  404. int rtp_mode; /* 1 for activate RTP friendly-mode */
  405. /* highers numbers represent more error-prone */
  406. /* enviroments, by now just "1" exist */
  407. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  408. /* do it's best to deliver a chunk with size */
  409. /* below rtp_payload_size, the chunk will start */
  410. /* with a start code on some codecs like H.263 */
  411. /* This doesn't take account of any particular */
  412. /* headers inside the transmited RTP payload */
  413. /* The RTP callcack: This function is called */
  414. /* every time the encoder as a packet to send */
  415. /* Depends on the encoder if the data starts */
  416. /* with a Start Code (it should) H.263 does */
  417. void (*rtp_callback)(void *data, int size, int packet_number);
  418. /* statistics, used for 2-pass encoding */
  419. int mv_bits;
  420. int header_bits;
  421. int i_tex_bits;
  422. int p_tex_bits;
  423. int i_count;
  424. int p_count;
  425. int skip_count;
  426. int misc_bits;
  427. /**
  428. * number of bits used for the previously encoded frame
  429. * encoding: set by lavc
  430. * decoding: - for audio - bits_per_sample
  431. */
  432. int frame_bits;
  433. /**
  434. * private data of the user, can be used to carry app specific stuff
  435. * encoding: set by user
  436. * decoding: set by user
  437. */
  438. void *opaque;
  439. char codec_name[32];
  440. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  441. enum CodecID codec_id; /* see CODEC_ID_xxx */
  442. unsigned int codec_tag; /* codec tag, only used if unknown codec */
  443. /**
  444. * workaround bugs in encoders which sometimes cannot be detected automatically
  445. * encoding: unused
  446. * decoding: set by user
  447. */
  448. int workaround_bugs;
  449. #define FF_BUG_AUTODETECT 1 //autodetection
  450. #define FF_BUG_OLD_MSMPEG4 2
  451. #define FF_BUG_XVID_ILACE 4
  452. #define FF_BUG_UMP4 8
  453. #define FF_BUG_NO_PADDING 16
  454. #define FF_BUG_AC_VLC 32
  455. #define FF_BUG_QPEL_CHROMA 64
  456. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  457. /**
  458. * encoding: set by user
  459. * decoding: unused
  460. */
  461. int luma_elim_threshold;
  462. /**
  463. * encoding: set by user
  464. * decoding: unused
  465. */
  466. int chroma_elim_threshold;
  467. /**
  468. * strictly follow the std (MPEG4, ...)
  469. * encoding: set by user
  470. * decoding: unused
  471. */
  472. int strict_std_compliance;
  473. /**
  474. * qscale offset between ip and b frames
  475. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  476. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  477. * encoding: set by user.
  478. * decoding: unused
  479. */
  480. float b_quant_offset;
  481. /**
  482. * error resilience higher values will detect more errors but may missdetect
  483. * some more or less valid parts as errors
  484. * encoding: unused
  485. * decoding: set by user
  486. */
  487. int error_resilience;
  488. #define FF_ER_CAREFULL 1
  489. #define FF_ER_COMPLIANT 2
  490. #define FF_ER_AGGRESSIVE 3
  491. #define FF_ER_VERY_AGGRESSIVE 4
  492. /**
  493. * called at the beginning of each frame to get a buffer for it.
  494. * if pic.reference is set then the frame will be read later by lavc
  495. * encoding: unused
  496. * decoding: set by lavc, user can override
  497. */
  498. int (*get_buffer)(struct AVCodecContext *c, AVVideoFrame *pic);
  499. /**
  500. * called to release buffers which where allocated with get_buffer.
  501. * a released buffer can be reused in get_buffer()
  502. * pic.data[*] must be set to NULL
  503. * encoding: unused
  504. * decoding: set by lavc, user can override
  505. */
  506. void (*release_buffer)(struct AVCodecContext *c, AVVideoFrame *pic);
  507. /**
  508. * is 1 if the decoded stream contains b frames, 0 otherwise
  509. * encoding: unused
  510. * decoding: set by lavc
  511. */
  512. int has_b_frames;
  513. int block_align; /* used by some WAV based audio codecs */
  514. int parse_only; /* decoding only: if true, only parsing is done
  515. (function avcodec_parse_frame()). The frame
  516. data is returned. Only MPEG codecs support this now. */
  517. /**
  518. * 0-> h263 quant 1-> mpeg quant
  519. * encoding: set by user.
  520. * decoding: unused
  521. */
  522. int mpeg_quant;
  523. /**
  524. * pass1 encoding statistics output buffer
  525. * encoding: set by lavc
  526. * decoding: unused
  527. */
  528. char *stats_out; /* encoding statistics output buffer */
  529. /**
  530. * pass2 encoding statistics input buffer.
  531. * concatenated stuff from stats_out of pass1 should be placed here
  532. * encoding: allocated/set/freed by user
  533. * decoding: unused
  534. */
  535. char *stats_in;
  536. /**
  537. * ratecontrol qmin qmax limiting method
  538. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  539. * encoding: set by user.
  540. * decoding: unused
  541. */
  542. float rc_qsquish;
  543. float rc_qmod_amp;
  544. int rc_qmod_freq;
  545. /**
  546. * ratecontrol override, see RcOverride
  547. * encoding: allocated/set/freed by user.
  548. * decoding: unused
  549. */
  550. RcOverride *rc_override;
  551. int rc_override_count;
  552. /**
  553. * rate control equation
  554. * encoding: set by user
  555. * decoding: unused
  556. */
  557. char *rc_eq;
  558. /**
  559. * maximum bitrate
  560. * encoding: set by user.
  561. * decoding: unused
  562. */
  563. int rc_max_rate;
  564. /**
  565. * minimum bitrate
  566. * encoding: set by user.
  567. * decoding: unused
  568. */
  569. int rc_min_rate;
  570. /**
  571. * decoder bitstream buffer size
  572. * encoding: set by user.
  573. * decoding: unused
  574. */
  575. int rc_buffer_size;
  576. float rc_buffer_aggressivity;
  577. /**
  578. * qscale factor between p and i frames
  579. * encoding: set by user.
  580. * decoding: unused
  581. */
  582. float i_quant_factor;
  583. /**
  584. * qscale offset between p and i frames
  585. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  586. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  587. * encoding: set by user.
  588. * decoding: unused
  589. */
  590. float i_quant_offset;
  591. /**
  592. * initial complexity for pass1 ratecontrol
  593. * encoding: set by user.
  594. * decoding: unused
  595. */
  596. float rc_initial_cplx;
  597. /**
  598. * dct algorithm, see FF_DCT_* below
  599. * encoding: set by user
  600. * decoding: unused
  601. */
  602. int dct_algo;
  603. #define FF_DCT_AUTO 0
  604. #define FF_DCT_FASTINT 1
  605. #define FF_DCT_INT 2
  606. #define FF_DCT_MMX 3
  607. #define FF_DCT_MLIB 4
  608. #define FF_DCT_ALTIVEC 5
  609. /**
  610. * luminance masking (0-> disabled)
  611. * encoding: set by user
  612. * decoding: unused
  613. */
  614. float lumi_masking;
  615. /**
  616. * temporary complexity masking (0-> disabled)
  617. * encoding: set by user
  618. * decoding: unused
  619. */
  620. float temporal_cplx_masking;
  621. /**
  622. * spatial complexity masking (0-> disabled)
  623. * encoding: set by user
  624. * decoding: unused
  625. */
  626. float spatial_cplx_masking;
  627. /**
  628. * p block masking (0-> disabled)
  629. * encoding: set by user
  630. * decoding: unused
  631. */
  632. float p_masking;
  633. /**
  634. * darkness masking (0-> disabled)
  635. * encoding: set by user
  636. * decoding: unused
  637. */
  638. float dark_masking;
  639. /**
  640. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
  641. * this is used to workaround some encoder bugs
  642. * encoding: unused
  643. * decoding: set by user, will be converted to upper case by lavc during init
  644. */
  645. int fourcc;
  646. /**
  647. * idct algorithm, see FF_IDCT_* below
  648. * encoding: set by user
  649. * decoding: set by user
  650. */
  651. int idct_algo;
  652. #define FF_IDCT_AUTO 0
  653. #define FF_IDCT_INT 1
  654. #define FF_IDCT_SIMPLE 2
  655. #define FF_IDCT_SIMPLEMMX 3
  656. #define FF_IDCT_LIBMPEG2MMX 4
  657. #define FF_IDCT_PS2 5
  658. #define FF_IDCT_MLIB 6
  659. #define FF_IDCT_ARM 7
  660. #define FF_IDCT_ALTIVEC 8
  661. /**
  662. * slice count
  663. * encoding: set by lavc
  664. * decoding: set by user (or 0)
  665. */
  666. int slice_count;
  667. /**
  668. * slice offsets in the frame in bytes
  669. * encoding: set/allocated by lavc
  670. * decoding: set/allocated by user (or NULL)
  671. */
  672. int *slice_offset;
  673. /**
  674. * error concealment flags
  675. * encoding: unused
  676. * decoding: set by user
  677. */
  678. int error_concealment;
  679. #define FF_EC_GUESS_MVS 1
  680. #define FF_EC_DEBLOCK 2
  681. /**
  682. * dsp_mask could be used to disable unwanted
  683. * CPU features (i.e. MMX, SSE. ...)
  684. */
  685. unsigned dsp_mask;
  686. /**
  687. * bits per sample/pixel from the demuxer (needed for huffyuv)
  688. * encoding: set by lavc
  689. * decoding: set by user
  690. */
  691. int bits_per_sample;
  692. /**
  693. * prediction method (needed for huffyuv)
  694. * encoding: set by user
  695. * decoding: unused
  696. */
  697. int prediction_method;
  698. #define FF_PRED_LEFT 0
  699. #define FF_PRED_PLANE 1
  700. #define FF_PRED_MEDIAN 2
  701. /**
  702. * aspect ratio. (0 if unknown)
  703. * encoding: set by user.
  704. * decoding: set by lavc.
  705. */
  706. float aspect_ratio;
  707. /**
  708. * the picture in the bitstream
  709. * encoding: set by lavc
  710. * decoding: set by lavc
  711. */
  712. AVVideoFrame *coded_picture;
  713. /**
  714. * debug
  715. * encoding: set by user.
  716. * decoding: set by user.
  717. */
  718. int debug;
  719. #define FF_DEBUG_PICT_INFO 1
  720. #define FF_DEBUG_RC 2
  721. #define FF_DEBUG_BITSTREAM 4
  722. #define FF_DEBUG_MB_TYPE 8
  723. #define FF_DEBUG_QP 16
  724. #define FF_DEBUG_MV 32
  725. #define FF_DEBUG_VIS_MV 64
  726. /**
  727. * error
  728. * encoding: set by lavc if flags&CODEC_FLAG_PSNR
  729. * decoding: unused
  730. */
  731. uint64_t error[4];
  732. } AVCodecContext;
  733. typedef struct AVCodec {
  734. const char *name;
  735. int type;
  736. int id;
  737. int priv_data_size;
  738. int (*init)(AVCodecContext *);
  739. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  740. int (*close)(AVCodecContext *);
  741. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  742. UINT8 *buf, int buf_size);
  743. int capabilities;
  744. struct AVCodec *next;
  745. } AVCodec;
  746. /**
  747. * four components are given, that's all.
  748. * the last component is alpha
  749. */
  750. typedef struct AVPicture {
  751. UINT8 *data[4];
  752. int linesize[4];
  753. } AVPicture;
  754. extern AVCodec ac3_encoder;
  755. extern AVCodec mp2_encoder;
  756. extern AVCodec mp3lame_encoder;
  757. extern AVCodec oggvorbis_encoder;
  758. extern AVCodec mpeg1video_encoder;
  759. extern AVCodec h263_encoder;
  760. extern AVCodec h263p_encoder;
  761. extern AVCodec rv10_encoder;
  762. extern AVCodec mjpeg_encoder;
  763. extern AVCodec mpeg4_encoder;
  764. extern AVCodec msmpeg4v1_encoder;
  765. extern AVCodec msmpeg4v2_encoder;
  766. extern AVCodec msmpeg4v3_encoder;
  767. extern AVCodec wmv1_encoder;
  768. extern AVCodec wmv2_encoder;
  769. extern AVCodec huffyuv_encoder;
  770. extern AVCodec h263_decoder;
  771. extern AVCodec mpeg4_decoder;
  772. extern AVCodec msmpeg4v1_decoder;
  773. extern AVCodec msmpeg4v2_decoder;
  774. extern AVCodec msmpeg4v3_decoder;
  775. extern AVCodec wmv1_decoder;
  776. extern AVCodec wmv2_decoder;
  777. extern AVCodec mpeg_decoder;
  778. extern AVCodec h263i_decoder;
  779. extern AVCodec rv10_decoder;
  780. extern AVCodec svq1_decoder;
  781. extern AVCodec dvvideo_decoder;
  782. extern AVCodec dvaudio_decoder;
  783. extern AVCodec wmav1_decoder;
  784. extern AVCodec wmav2_decoder;
  785. extern AVCodec mjpeg_decoder;
  786. extern AVCodec mjpegb_decoder;
  787. extern AVCodec mp2_decoder;
  788. extern AVCodec mp3_decoder;
  789. extern AVCodec mace3_decoder;
  790. extern AVCodec mace6_decoder;
  791. extern AVCodec huffyuv_decoder;
  792. extern AVCodec oggvorbis_decoder;
  793. /* pcm codecs */
  794. #define PCM_CODEC(id, name) \
  795. extern AVCodec name ## _decoder; \
  796. extern AVCodec name ## _encoder
  797. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  798. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  799. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  800. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  801. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  802. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  803. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  804. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  805. /* adpcm codecs */
  806. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  807. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  808. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  809. #undef PCM_CODEC
  810. /* dummy raw video codec */
  811. extern AVCodec rawvideo_codec;
  812. /* the following codecs use external GPL libs */
  813. extern AVCodec ac3_decoder;
  814. /* resample.c */
  815. struct ReSampleContext;
  816. typedef struct ReSampleContext ReSampleContext;
  817. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  818. int output_rate, int input_rate);
  819. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  820. void audio_resample_close(ReSampleContext *s);
  821. /* YUV420 format is assumed ! */
  822. struct ImgReSampleContext;
  823. typedef struct ImgReSampleContext ImgReSampleContext;
  824. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  825. int input_width, int input_height);
  826. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  827. int iwidth, int iheight,
  828. int topBand, int bottomBand,
  829. int leftBand, int rightBand);
  830. void img_resample(ImgReSampleContext *s,
  831. AVPicture *output, AVPicture *input);
  832. void img_resample_close(ImgReSampleContext *s);
  833. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  834. int pix_fmt, int width, int height);
  835. int avpicture_get_size(int pix_fmt, int width, int height);
  836. void avcodec_get_chroma_sub_sample(int fmt, int *h_shift, int *v_shift);
  837. /* convert among pixel formats */
  838. int img_convert(AVPicture *dst, int dst_pix_fmt,
  839. AVPicture *src, int pix_fmt,
  840. int width, int height);
  841. /* deinterlace a picture */
  842. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  843. int pix_fmt, int width, int height);
  844. /* external high level API */
  845. extern AVCodec *first_avcodec;
  846. /* returns LIBAVCODEC_VERSION_INT constant */
  847. unsigned avcodec_version(void);
  848. /* returns LIBAVCODEC_BUILD constant */
  849. unsigned avcodec_build(void);
  850. void avcodec_init(void);
  851. void avcodec_set_bit_exact(void);
  852. void register_avcodec(AVCodec *format);
  853. AVCodec *avcodec_find_encoder(enum CodecID id);
  854. AVCodec *avcodec_find_encoder_by_name(const char *name);
  855. AVCodec *avcodec_find_decoder(enum CodecID id);
  856. AVCodec *avcodec_find_decoder_by_name(const char *name);
  857. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  858. void avcodec_get_context_defaults(AVCodecContext *s);
  859. AVCodecContext *avcodec_alloc_context(void);
  860. AVVideoFrame *avcodec_alloc_picture(void);
  861. int avcodec_default_get_buffer(AVCodecContext *s, AVVideoFrame *pic);
  862. void avcodec_default_release_buffer(AVCodecContext *s, AVVideoFrame *pic);
  863. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  864. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  865. int *frame_size_ptr,
  866. UINT8 *buf, int buf_size);
  867. int avcodec_decode_video(AVCodecContext *avctx, AVVideoFrame *picture,
  868. int *got_picture_ptr,
  869. UINT8 *buf, int buf_size);
  870. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  871. int *data_size_ptr,
  872. UINT8 *buf, int buf_size);
  873. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  874. const short *samples);
  875. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  876. const AVVideoFrame *pict);
  877. int avcodec_close(AVCodecContext *avctx);
  878. void avcodec_register_all(void);
  879. void avcodec_flush_buffers(AVCodecContext *avctx);
  880. /**
  881. * Interface for 0.5.0 version
  882. *
  883. * do not even think about it's usage for this moment
  884. */
  885. typedef struct {
  886. // compressed size used from given memory buffer
  887. int size;
  888. /// I/P/B frame type
  889. int frame_type;
  890. } avc_enc_result_t;
  891. /**
  892. * Commands
  893. * order can't be changed - once it was defined
  894. */
  895. typedef enum {
  896. // general commands
  897. AVC_OPEN_BY_NAME = 0xACA000,
  898. AVC_OPEN_BY_CODEC_ID,
  899. AVC_OPEN_BY_FOURCC,
  900. AVC_CLOSE,
  901. AVC_FLUSH,
  902. // pin - struct { uint8_t* src, uint_t src_size }
  903. // pout - struct { AVPicture* img, consumed_bytes,
  904. AVC_DECODE,
  905. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  906. // pout - uint_t used_from_dest_size
  907. AVC_ENCODE,
  908. // query/get video commands
  909. AVC_GET_VERSION = 0xACB000,
  910. AVC_GET_WIDTH,
  911. AVC_GET_HEIGHT,
  912. AVC_GET_DELAY,
  913. AVC_GET_QUANT_TABLE,
  914. // ...
  915. // query/get audio commands
  916. AVC_GET_FRAME_SIZE = 0xABC000,
  917. // maybe define some simple structure which
  918. // might be passed to the user - but they can't
  919. // contain any codec specific parts and these
  920. // calls are usualy necessary only few times
  921. // set video commands
  922. AVC_SET_WIDTH = 0xACD000,
  923. AVC_SET_HEIGHT,
  924. // set video encoding commands
  925. AVC_SET_FRAME_RATE = 0xACD800,
  926. AVC_SET_QUALITY,
  927. AVC_SET_HURRY_UP,
  928. // set audio commands
  929. AVC_SET_SAMPLE_RATE = 0xACE000,
  930. AVC_SET_CHANNELS,
  931. } avc_cmd_t;
  932. /**
  933. * \param handle allocated private structure by libavcodec
  934. * for initialization pass NULL - will be returned pout
  935. * user is supposed to know nothing about its structure
  936. * \param cmd type of operation to be performed
  937. * \param pint input parameter
  938. * \param pout output parameter
  939. *
  940. * \returns command status - eventually for query command it might return
  941. * integer resulting value
  942. */
  943. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  944. /* memory */
  945. void *av_malloc(unsigned int size);
  946. void *av_mallocz(unsigned int size);
  947. void av_free(void *ptr);
  948. void __av_freep(void **ptr);
  949. #define av_freep(p) __av_freep((void **)(p))
  950. /* for static data only */
  951. /* call av_free_static to release all staticaly allocated tables */
  952. void av_free_static();
  953. void *__av_mallocz_static(void** location, unsigned int size);
  954. #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
  955. #endif /* AVCODEC_H */