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.

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