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.

1041 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 4631
  7. #define LIBAVCODEC_BUILD_STR "4631"
  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_MPEG4,
  19. CODEC_ID_RAWVIDEO,
  20. CODEC_ID_MSMPEG4V1,
  21. CODEC_ID_MSMPEG4V2,
  22. CODEC_ID_MSMPEG4V3,
  23. CODEC_ID_WMV1,
  24. CODEC_ID_WMV2,
  25. CODEC_ID_H263P,
  26. CODEC_ID_H263I,
  27. CODEC_ID_SVQ1,
  28. CODEC_ID_DVVIDEO,
  29. CODEC_ID_DVAUDIO,
  30. /* various pcm "codecs" */
  31. CODEC_ID_PCM_S16LE,
  32. CODEC_ID_PCM_S16BE,
  33. CODEC_ID_PCM_U16LE,
  34. CODEC_ID_PCM_U16BE,
  35. CODEC_ID_PCM_S8,
  36. CODEC_ID_PCM_U8,
  37. CODEC_ID_PCM_MULAW,
  38. CODEC_ID_PCM_ALAW,
  39. /* various adpcm codecs */
  40. CODEC_ID_ADPCM_IMA_QT,
  41. CODEC_ID_ADPCM_IMA_WAV,
  42. CODEC_ID_ADPCM_MS,
  43. };
  44. #define CODEC_ID_MSMPEG4 CODEC_ID_MSMPEG4V3
  45. enum CodecType {
  46. CODEC_TYPE_UNKNOWN = -1,
  47. CODEC_TYPE_VIDEO,
  48. CODEC_TYPE_AUDIO,
  49. };
  50. enum PixelFormat {
  51. PIX_FMT_ANY = -1,
  52. PIX_FMT_YUV420P,
  53. PIX_FMT_YUV422,
  54. PIX_FMT_RGB24,
  55. PIX_FMT_BGR24,
  56. PIX_FMT_YUV422P,
  57. PIX_FMT_YUV444P,
  58. PIX_FMT_RGBA32,
  59. PIX_FMT_BGRA32,
  60. PIX_FMT_YUV410P,
  61. PIX_FMT_YUV411P
  62. };
  63. /* currently unused, may be used if 24/32 bits samples ever supported */
  64. enum SampleFormat {
  65. SAMPLE_FMT_S16 = 0, /* signed 16 bits */
  66. };
  67. /* in bytes */
  68. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 18432
  69. /* motion estimation type, EPZS by default */
  70. enum Motion_Est_ID {
  71. ME_ZERO = 1,
  72. ME_FULL,
  73. ME_LOG,
  74. ME_PHODS,
  75. ME_EPZS,
  76. ME_X1
  77. };
  78. typedef struct RcOverride{
  79. int start_frame;
  80. int end_frame;
  81. int qscale; // if this is 0 then quality_factor will be used instead
  82. float quality_factor;
  83. } RcOverride;
  84. /* only for ME compatiblity with old apps */
  85. extern int motion_estimation_method;
  86. /* ME algos sorted by quality */
  87. static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
  88. ME_X1, ME_EPZS, ME_FULL };
  89. #define FF_MAX_B_FRAMES 4
  90. /* encoding support
  91. these flags can be passed in AVCodecContext.flags before initing
  92. Note: note not everything is supported yet
  93. */
  94. #define CODEC_FLAG_HQ 0x0001 /* brute force MB-type decission mode (slow) */
  95. #define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
  96. #define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */
  97. #define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */
  98. #define CODEC_FLAG_GMC 0x0020 /* use GMC */
  99. #define CODEC_FLAG_TYPE 0x0040 /* fixed I/P frame type, from avctx->key_frame */
  100. #define CODEC_FLAG_PART 0x0080 /* use data partitioning */
  101. /* parent program gurantees that the input for b-frame containing streams is not written to
  102. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  103. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  104. #define CODEC_FLAG_PASS1 0x0200 /* use internal 2pass ratecontrol in first pass mode */
  105. #define CODEC_FLAG_PASS2 0x0400 /* use internal 2pass ratecontrol in second pass mode */
  106. #define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */
  107. #define CODEC_FLAG_GRAY 0x2000 /* only decode/encode grayscale */
  108. #define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */
  109. #define CODEC_FLAG_DR1 0x8000 /* direct renderig type 1 (store internal frames in external buffers) */
  110. #define CODEC_FLAG_NOT_TRUNCATED 0x00010000 /* input bitstream is not truncated, except before a startcode
  111. allows the last part of a frame to be decoded earlier */
  112. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 /* normalize adaptive quantization */
  113. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */
  114. /* codec capabilities */
  115. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 /* decoder can use draw_horiz_band callback */
  116. #define CODEC_CAP_DR1 0x0002 /* direct rendering method 1 */
  117. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  118. used */
  119. #define CODEC_CAP_PARSE_ONLY 0x0004
  120. #define FRAME_RATE_BASE 10000
  121. typedef struct AVCodecContext {
  122. /**
  123. * the average bitrate
  124. * encoding: set by user. unused for constant quantizer encoding
  125. * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  126. */
  127. int bit_rate;
  128. /**
  129. * number of bits the bitstream is allowed to diverge from the reference
  130. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  131. * encoding: set by user. unused for constant quantizer encoding
  132. * decoding: unused
  133. */
  134. int bit_rate_tolerance;
  135. /**
  136. * CODEC_FLAG_*
  137. * encoding: set by user.
  138. * decoding: set by user.
  139. */
  140. int flags;
  141. /**
  142. * some codecs needs additionnal format info. It is stored here
  143. * encoding: set by user.
  144. * decoding: set by lavc. (FIXME is this ok?)
  145. */
  146. int sub_id;
  147. /**
  148. * motion estimation algorithm used for video coding
  149. * encoding: set by user.
  150. * decoding: unused
  151. */
  152. int me_method;
  153. /**
  154. * some codecs need / can use extra-data like huffman tables
  155. * mjpeg: huffman tables
  156. * rv10: additional flags
  157. * encoding: set/allocated/freed by lavc.
  158. * decoding: set/allocated/freed by user.
  159. */
  160. void *extradata;
  161. int extradata_size;
  162. /* video only */
  163. /**
  164. * frames per sec multiplied by FRAME_RATE_BASE
  165. * for variable fps this is the precission, so if the timestamps
  166. * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
  167. * encoding: set by user
  168. * decoding: set by lavc. 0 or the frame_rate if available
  169. */
  170. int frame_rate;
  171. /**
  172. * encoding: set by user.
  173. * decoding: set by user, some codecs might override / change it during playback
  174. */
  175. int width, height;
  176. /**
  177. * encoding: set by user. 0 if not known
  178. * decoding: set by lavc. 0 if not known
  179. */
  180. int aspect_ratio_info;
  181. #define FF_ASPECT_SQUARE 1
  182. #define FF_ASPECT_4_3_625 2
  183. #define FF_ASPECT_4_3_525 3
  184. #define FF_ASPECT_16_9_625 4
  185. #define FF_ASPECT_16_9_525 5
  186. #define FF_ASPECT_EXTENDED 15
  187. /**
  188. * the number of pictures in a group of pitures, or 0 for intra_only
  189. * encoding: set by user.
  190. * decoding: unused
  191. */
  192. int gop_size;
  193. /**
  194. * pixel format, see PIX_FMT_xxx
  195. * encoding: unused
  196. * decoding: set by lavc.
  197. */
  198. enum PixelFormat pix_fmt;
  199. int repeat_pict; /* when decoding, this signal how much the picture */
  200. /* must be delayed. */
  201. /* extra_delay = (repeat_pict / 2) * (1/fps) */
  202. /**
  203. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  204. * decoder to draw an horizontal band. It improve cache usage. Not
  205. * all codecs can do that. You must check the codec capabilities
  206. * before
  207. * encoding: unused
  208. * decoding: set by user.
  209. */
  210. void (*draw_horiz_band)(struct AVCodecContext *s,
  211. UINT8 **src_ptr, int linesize,
  212. int y, int width, int height);
  213. /* audio only */
  214. int sample_rate; /* samples per sec */
  215. int channels;
  216. int sample_fmt; /* sample format, currenly unused */
  217. /* the following data should not be initialized */
  218. int frame_size; /* in samples, initialized when calling 'init' */
  219. int frame_number; /* audio or video frame number */
  220. int real_pict_num; /* returns the real picture number of
  221. previous encoded frame */
  222. /**
  223. * 1 -> keyframe, 0-> not
  224. * encoding: set by lavc (for the outputed bitstream, not the input frame)
  225. * decoding: set by lavc (for the decoded bitstream, not the displayed frame)
  226. */
  227. int key_frame;
  228. /**
  229. * picture type of the previous en/decoded frame, see ?_TYPE below
  230. * encoding: set by lavc (for the outputed bitstream, not the input frame)
  231. * decoding: set by lavc (for the decoded bitstream, not the displayed frame)
  232. */
  233. int pict_type;
  234. /* FIXME: these should have FF_ */
  235. #define I_TYPE 1 // Intra
  236. #define P_TYPE 2 // Predicted
  237. #define B_TYPE 3 // Bi-dir predicted
  238. #define S_TYPE 4 // S(GMC)-VOP MPEG4
  239. /**
  240. * number of frames the decoded output will be delayed relative to
  241. * the encoded input
  242. * encoding: set by lavc.
  243. * decoding: unused
  244. */
  245. int delay;
  246. /**
  247. * mbskip_table[mb]=1 if MB didnt change, is only valid for I/P frames
  248. * stride= mb_width = (width+15)>>4 (FIXME export stride?)
  249. * encoding: unused
  250. * decoding: set by lavc
  251. */
  252. uint8_t *mbskip_table;
  253. /* encoding parameters */
  254. /**
  255. * quality (between 1 (good) and 31 (bad))
  256. * encoding: set by user if CODEC_FLAG_QSCALE is set otherwise set by lavc
  257. * decoding: set by lavc
  258. */
  259. int quality; /* quality of the previous encoded frame
  260. this is allso used to set the quality in vbr mode
  261. and the per frame quality in CODEC_FLAG_TYPE (second pass mode) */
  262. float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
  263. float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
  264. /**
  265. * minimum quantizer
  266. * encoding: set by user.
  267. * decoding: unused
  268. */
  269. int qmin;
  270. /**
  271. * maximum quantizer
  272. * encoding: set by user.
  273. * decoding: unused
  274. */
  275. int qmax;
  276. /**
  277. * maximum quantizer difference etween frames
  278. * encoding: set by user.
  279. * decoding: unused
  280. */
  281. int max_qdiff;
  282. /**
  283. * maximum number of b frames between non b frames
  284. * note: the output will be delayed by max_b_frames+1 relative to the input
  285. * encoding: set by user.
  286. * decoding: unused
  287. */
  288. int max_b_frames;
  289. /**
  290. * qscale factor between ip and b frames
  291. * encoding: set by user.
  292. * decoding: unused
  293. */
  294. float b_quant_factor;
  295. /** obsolete FIXME remove */
  296. int rc_strategy;
  297. int b_frame_strategy;
  298. /**
  299. * encoding: unused
  300. * decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too
  301. */
  302. int hurry_up;
  303. struct AVCodec *codec;
  304. void *priv_data;
  305. /* The following data is for RTP friendly coding */
  306. /* By now only H.263/H.263+/MPEG4 coder honours this */
  307. int rtp_mode; /* 1 for activate RTP friendly-mode */
  308. /* highers numbers represent more error-prone */
  309. /* enviroments, by now just "1" exist */
  310. int rtp_payload_size; /* The size of the RTP payload, the coder will */
  311. /* do it's best to deliver a chunk with size */
  312. /* below rtp_payload_size, the chunk will start */
  313. /* with a start code on some codecs like H.263 */
  314. /* This doesn't take account of any particular */
  315. /* headers inside the transmited RTP payload */
  316. /* The RTP callcack: This function is called */
  317. /* every time the encoder as a packet to send */
  318. /* Depends on the encoder if the data starts */
  319. /* with a Start Code (it should) H.263 does */
  320. void (*rtp_callback)(void *data, int size, int packet_number);
  321. /**
  322. * if you set get_psnr to 1 then after encoding you will have the
  323. * PSNR on psnr_y/cb/cr
  324. * encoding: set by user (1-> on, 0-> off)
  325. * decoding: unused
  326. */
  327. int get_psnr;
  328. float psnr_y;
  329. float psnr_cb;
  330. float psnr_cr;
  331. /* statistics, used for 2-pass encoding */
  332. int mv_bits;
  333. int header_bits;
  334. int i_tex_bits;
  335. int p_tex_bits;
  336. int i_count;
  337. int p_count;
  338. int skip_count;
  339. int misc_bits;
  340. /**
  341. * number of bits used for the previously encoded frame
  342. * encoding: set by lavc
  343. * decoding: unused
  344. */
  345. int frame_bits;
  346. /**
  347. * private data of the user, can be used to carry app specific stuff
  348. * encoding: set by user
  349. * decoding: set by user
  350. */
  351. void *opaque;
  352. char codec_name[32];
  353. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  354. enum CodecID codec_id; /* see CODEC_ID_xxx */
  355. unsigned int codec_tag; /* codec tag, only used if unknown codec */
  356. /**
  357. * workaround bugs in encoders which sometimes cannot be detected automatically
  358. * encoding: unused
  359. * decoding: set by user
  360. */
  361. int workaround_bugs;
  362. #define FF_BUG_AUTODETECT 1 //autodetection
  363. #define FF_BUG_OLD_MSMPEG4 2
  364. #define FF_BUG_XVID_ILACE 4
  365. #define FF_BUG_UMP4 8
  366. #define FF_BUG_NO_PADDING 16
  367. #define FF_BUG_AC_VLC 32
  368. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  369. /**
  370. * encoding: set by user
  371. * decoding: unused
  372. */
  373. int luma_elim_threshold;
  374. /**
  375. * encoding: set by user
  376. * decoding: unused
  377. */
  378. int chroma_elim_threshold;
  379. /**
  380. * strictly follow the std (MPEG4, ...)
  381. * encoding: set by user
  382. * decoding: unused
  383. */
  384. int strict_std_compliance;
  385. /**
  386. * qscale offset between ip and b frames
  387. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  388. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  389. * encoding: set by user.
  390. * decoding: unused
  391. */
  392. float b_quant_offset;
  393. /**
  394. * error resilience {-1,0,1} higher values will detect more errors but may missdetect
  395. * some more or less valid parts as errors
  396. * encoding: unused
  397. * decoding: set by user
  398. */
  399. int error_resilience;
  400. #ifndef MBC
  401. #define MBC 128
  402. #define MBR 96
  403. #endif
  404. #define QP_TYPE int //FIXME note xxx this might be changed to int8_t
  405. QP_TYPE *quant_store; /* field for communicating with external postprocessing */
  406. unsigned qstride;
  407. /**
  408. * buffer, where the next picture should be decoded into
  409. * encoding: unused
  410. * decoding: set by user in get_buffer_callback to a buffer into which the next part
  411. * of the bitstream will be decoded, and set by lavc at end of frame to the
  412. * next frame which needs to be displayed
  413. */
  414. uint8_t *dr_buffer[3];
  415. /**
  416. * stride of the luminance part of the dr buffer
  417. * encoding: unused
  418. * decoding: set by user
  419. */
  420. int dr_stride;
  421. /**
  422. * same behavior as dr_buffer, just for some private data of the user
  423. * encoding: unused
  424. * decoding: set by user in get_buffer_callback, and set by lavc at end of frame
  425. */
  426. void *dr_opaque_frame;
  427. /**
  428. * called at the beginning of each frame to get a buffer for it
  429. * encoding: unused
  430. * decoding: set by user
  431. */
  432. void (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type);
  433. /**
  434. * is 1 if the decoded stream contains b frames, 0 otherwise
  435. * encoding: unused
  436. * decoding: set by lavc
  437. */
  438. int has_b_frames;
  439. /**
  440. * stride of the chrominance part of the dr buffer
  441. * encoding: unused
  442. * decoding: set by user
  443. */
  444. int dr_uvstride;
  445. /**
  446. * number of dr buffers
  447. * encoding: unused
  448. * decoding: set by user
  449. */
  450. int dr_ip_buffer_count;
  451. int block_align; /* currently only for adpcm codec in wav/avi */
  452. int parse_only; /* decoding only: if true, only parsing is done
  453. (function avcodec_parse_frame()). The frame
  454. data is returned. Only MPEG codecs support this now. */
  455. /**
  456. * 0-> h263 quant 1-> mpeg quant
  457. * encoding: set by user.
  458. * decoding: unused
  459. */
  460. int mpeg_quant;
  461. /**
  462. * pass1 encoding statistics output buffer
  463. * encoding: set by lavc
  464. * decoding: unused
  465. */
  466. char *stats_out; /* encoding statistics output buffer */
  467. /**
  468. * pass2 encoding statistics input buffer.
  469. * concatenated stuff from stats_out of pass1 should be placed here
  470. * encoding: allocated/set/freed by user
  471. * decoding: unused
  472. */
  473. char *stats_in;
  474. /**
  475. * ratecontrol qmin qmax limiting method
  476. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  477. * encoding: set by user.
  478. * decoding: unused
  479. */
  480. float rc_qsquish;
  481. float rc_qmod_amp;
  482. int rc_qmod_freq;
  483. /**
  484. * ratecontrol override, see RcOverride
  485. * encoding: allocated/set/freed by user.
  486. * decoding: unused
  487. */
  488. RcOverride *rc_override;
  489. int rc_override_count;
  490. /**
  491. * rate control equation
  492. * encoding: set by user
  493. * decoding: unused
  494. */
  495. char *rc_eq;
  496. /**
  497. * maximum bitrate
  498. * encoding: set by user.
  499. * decoding: unused
  500. */
  501. int rc_max_rate;
  502. /**
  503. * minimum bitrate
  504. * encoding: set by user.
  505. * decoding: unused
  506. */
  507. int rc_min_rate;
  508. /**
  509. * decoder bitstream buffer size
  510. * encoding: set by user.
  511. * decoding: unused
  512. */
  513. int rc_buffer_size;
  514. float rc_buffer_aggressivity;
  515. /**
  516. * qscale factor between p and i frames
  517. * encoding: set by user.
  518. * decoding: unused
  519. */
  520. float i_quant_factor;
  521. /**
  522. * qscale offset between p and i frames
  523. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  524. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  525. * encoding: set by user.
  526. * decoding: unused
  527. */
  528. float i_quant_offset;
  529. /**
  530. * initial complexity for pass1 ratecontrol
  531. * encoding: set by user.
  532. * decoding: unused
  533. */
  534. float rc_initial_cplx;
  535. /**
  536. * custom aspect ratio, used if aspect_info==FF_ASPECT_EXTENDED
  537. * encoding: set by user.
  538. * decoding: set by lavc.
  539. */
  540. int aspected_width;
  541. int aspected_height;
  542. /**
  543. * dct algorithm, see FF_DCT_* below
  544. * encoding: set by user
  545. * decoding: unused
  546. */
  547. int dct_algo;
  548. #define FF_DCT_AUTO 0
  549. #define FF_DCT_FASTINT 1
  550. #define FF_DCT_INT 2
  551. #define FF_DCT_MMX 3
  552. #define FF_DCT_MLIB 4
  553. /**
  554. * presentation timestamp in micro seconds (time when frame should be shown to user)
  555. * if 0 then the frame_rate will be used as reference
  556. * encoding: set by user
  557. * decoding; set by lavc
  558. */
  559. long long int pts;
  560. /**
  561. * luminance masking (0-> disabled)
  562. * encoding: set by user
  563. * decoding: unused
  564. */
  565. float lumi_masking;
  566. /**
  567. * temporary complexity masking (0-> disabled)
  568. * encoding: set by user
  569. * decoding: unused
  570. */
  571. float temporal_cplx_masking;
  572. /**
  573. * spatial complexity masking (0-> disabled)
  574. * encoding: set by user
  575. * decoding: unused
  576. */
  577. float spatial_cplx_masking;
  578. /**
  579. * p block masking (0-> disabled)
  580. * encoding: set by user
  581. * decoding: unused
  582. */
  583. float p_masking;
  584. /**
  585. * darkness masking (0-> disabled)
  586. * encoding: set by user
  587. * decoding: unused
  588. */
  589. float dark_masking;
  590. /**
  591. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
  592. * this is used to workaround some encoder bugs
  593. * encoding: unused
  594. * decoding: set by user, will be converted to upper case by lavc during init
  595. */
  596. int fourcc;
  597. /**
  598. * idct algorithm, see FF_IDCT_* below
  599. * encoding: set by user
  600. * decoding: set by user
  601. */
  602. int idct_algo;
  603. #define FF_IDCT_AUTO 0
  604. #define FF_IDCT_INT 1
  605. #define FF_IDCT_SIMPLE 2
  606. #define FF_IDCT_SIMPLEMMX 3
  607. #define FF_IDCT_LIBMPEG2MMX 4
  608. #define FF_IDCT_PS2 5
  609. #define FF_IDCT_MLIB 6
  610. #define FF_IDCT_ARM 7
  611. /**
  612. * slice count
  613. * encoding: set by lavc
  614. * decoding: set by user (or 0)
  615. */
  616. int slice_count;
  617. /**
  618. * slice offsets in the frame in bytes
  619. * encoding: set/allocated by lavc
  620. * decoding: set/allocated by user (or NULL)
  621. */
  622. int *slice_offset;
  623. /**
  624. * error concealment flags
  625. * encoding: unused
  626. * decoding: set by user
  627. */
  628. int error_concealment;
  629. #define FF_EC_GUESS_MVS 1
  630. #define FF_EC_DEBLOCK 2
  631. //FIXME this should be reordered after kabis API is finished ...
  632. //TODO kill kabi
  633. /*
  634. Note: Below are located reserved fields for further usage
  635. It requires for ABI !!!
  636. If you'll perform some changes then borrow new space from these fields
  637. (void * can be safety replaced with struct * ;)
  638. P L E A S E ! ! !
  639. Note: use avcodec_alloc_context instead of malloc to allocate this,
  640. otherwise the ABI compatibility will be broken between versions
  641. IMPORTANT: Never change order of already declared fields!!!
  642. */
  643. //TODO: remove mess below
  644. unsigned long long int
  645. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  646. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11;
  647. float
  648. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  649. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  650. void
  651. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  652. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  653. unsigned long int
  654. ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5,
  655. ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12;
  656. unsigned short int
  657. us_res0,us_res1,us_res2,us_res3,us_res4,us_res5,
  658. us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
  659. unsigned char
  660. uc_res0,uc_res1,uc_res2,uc_res3,uc_res4,uc_res5,
  661. uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12;
  662. unsigned int
  663. ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5,ui_res6,ui_res7,ui_res8,ui_res9,
  664. ui_res10,ui_res11,ui_res12,ui_res13,ui_res14,ui_res15,ui_res16;
  665. } AVCodecContext;
  666. typedef struct AVCodec {
  667. char *name;
  668. int type;
  669. int id;
  670. int priv_data_size;
  671. int (*init)(AVCodecContext *);
  672. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  673. int (*close)(AVCodecContext *);
  674. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  675. UINT8 *buf, int buf_size);
  676. int capabilities;
  677. struct AVCodec *next;
  678. /*
  679. Note: Below are located reserved fields for further usage
  680. It requires for ABI !!!
  681. If you'll perform some changes then borrow new space from these fields
  682. (void * can be safety replaced with struct * ;)
  683. P L E A S E ! ! !
  684. IMPORTANT: Never change order of already declared fields!!!
  685. */
  686. unsigned long long int
  687. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  688. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11,ull_res12;
  689. float
  690. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  691. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  692. void
  693. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  694. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  695. } AVCodec;
  696. /* three components are given, that's all */
  697. typedef struct AVPicture {
  698. UINT8 *data[3];
  699. int linesize[3];
  700. } AVPicture;
  701. extern AVCodec ac3_encoder;
  702. extern AVCodec mp2_encoder;
  703. extern AVCodec mp3lame_encoder;
  704. extern AVCodec oggvorbis_encoder;
  705. extern AVCodec mpeg1video_encoder;
  706. extern AVCodec h263_encoder;
  707. extern AVCodec h263p_encoder;
  708. extern AVCodec rv10_encoder;
  709. extern AVCodec mjpeg_encoder;
  710. extern AVCodec mpeg4_encoder;
  711. extern AVCodec msmpeg4v1_encoder;
  712. extern AVCodec msmpeg4v2_encoder;
  713. extern AVCodec msmpeg4v3_encoder;
  714. extern AVCodec wmv1_encoder;
  715. extern AVCodec wmv2_encoder;
  716. extern AVCodec h263_decoder;
  717. extern AVCodec mpeg4_decoder;
  718. extern AVCodec msmpeg4v1_decoder;
  719. extern AVCodec msmpeg4v2_decoder;
  720. extern AVCodec msmpeg4v3_decoder;
  721. extern AVCodec wmv1_decoder;
  722. extern AVCodec wmv2_decoder;
  723. extern AVCodec mpeg_decoder;
  724. extern AVCodec h263i_decoder;
  725. extern AVCodec rv10_decoder;
  726. extern AVCodec svq1_decoder;
  727. extern AVCodec dvvideo_decoder;
  728. extern AVCodec dvaudio_decoder;
  729. extern AVCodec mjpeg_decoder;
  730. extern AVCodec mp2_decoder;
  731. extern AVCodec mp3_decoder;
  732. /* pcm codecs */
  733. #define PCM_CODEC(id, name) \
  734. extern AVCodec name ## _decoder; \
  735. extern AVCodec name ## _encoder;
  736. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  737. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  738. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  739. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  740. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  741. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  742. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  743. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  744. /* adpcm codecs */
  745. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  746. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  747. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  748. #undef PCM_CODEC
  749. /* dummy raw video codec */
  750. extern AVCodec rawvideo_codec;
  751. /* the following codecs use external GPL libs */
  752. extern AVCodec ac3_decoder;
  753. /* resample.c */
  754. struct ReSampleContext;
  755. typedef struct ReSampleContext ReSampleContext;
  756. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  757. int output_rate, int input_rate);
  758. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  759. void audio_resample_close(ReSampleContext *s);
  760. /* YUV420 format is assumed ! */
  761. struct ImgReSampleContext;
  762. typedef struct ImgReSampleContext ImgReSampleContext;
  763. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  764. int input_width, int input_height);
  765. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  766. int iwidth, int iheight,
  767. int topBand, int bottomBand,
  768. int leftBand, int rightBand);
  769. void img_resample(ImgReSampleContext *s,
  770. AVPicture *output, AVPicture *input);
  771. void img_resample_close(ImgReSampleContext *s);
  772. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  773. int pix_fmt, int width, int height);
  774. int avpicture_get_size(int pix_fmt, int width, int height);
  775. /* convert among pixel formats */
  776. int img_convert(AVPicture *dst, int dst_pix_fmt,
  777. AVPicture *src, int pix_fmt,
  778. int width, int height);
  779. /* deinterlace a picture */
  780. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  781. int pix_fmt, int width, int height);
  782. /* external high level API */
  783. extern AVCodec *first_avcodec;
  784. /* returns LIBAVCODEC_VERSION_INT constant */
  785. unsigned avcodec_version(void);
  786. /* returns LIBAVCODEC_BUILD constant */
  787. unsigned avcodec_build(void);
  788. void avcodec_init(void);
  789. void avcodec_set_bit_exact(void);
  790. void register_avcodec(AVCodec *format);
  791. AVCodec *avcodec_find_encoder(enum CodecID id);
  792. AVCodec *avcodec_find_encoder_by_name(const char *name);
  793. AVCodec *avcodec_find_decoder(enum CodecID id);
  794. AVCodec *avcodec_find_decoder_by_name(const char *name);
  795. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  796. AVCodecContext *avcodec_alloc_context(void);
  797. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  798. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  799. int *frame_size_ptr,
  800. UINT8 *buf, int buf_size);
  801. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  802. int *got_picture_ptr,
  803. UINT8 *buf, int buf_size);
  804. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  805. int *data_size_ptr,
  806. UINT8 *buf, int buf_size);
  807. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  808. const short *samples);
  809. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  810. const AVPicture *pict);
  811. int avcodec_close(AVCodecContext *avctx);
  812. void avcodec_register_all(void);
  813. void avcodec_flush_buffers(AVCodecContext *avctx);
  814. #ifdef FF_POSTPROCESS
  815. extern int quant_store[MBR+1][MBC+1]; // [Review]
  816. #endif
  817. /**
  818. * Interface for 0.5.0 version
  819. *
  820. * do not even think about it's usage for this moment
  821. */
  822. typedef struct {
  823. // compressed size used from given memory buffer
  824. int size;
  825. /// I/P/B frame type
  826. int frame_type;
  827. } avc_enc_result_t;
  828. /**
  829. * Commands
  830. * order can't be changed - once it was defined
  831. */
  832. typedef enum {
  833. // general commands
  834. AVC_OPEN_BY_NAME = 0xACA000,
  835. AVC_OPEN_BY_CODEC_ID,
  836. AVC_OPEN_BY_FOURCC,
  837. AVC_CLOSE,
  838. AVC_FLUSH,
  839. // pin - struct { uint8_t* src, uint_t src_size }
  840. // pout - struct { AVPicture* img, consumed_bytes,
  841. AVC_DECODE,
  842. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  843. // pout - uint_t used_from_dest_size
  844. AVC_ENCODE,
  845. // query/get video commands
  846. AVC_GET_VERSION = 0xACB000,
  847. AVC_GET_WIDTH,
  848. AVC_GET_HEIGHT,
  849. AVC_GET_DELAY,
  850. AVC_GET_QUANT_TABLE,
  851. // ...
  852. // query/get audio commands
  853. AVC_GET_FRAME_SIZE = 0xABC000,
  854. // maybe define some simple structure which
  855. // might be passed to the user - but they can't
  856. // contain any codec specific parts and these
  857. // calls are usualy necessary only few times
  858. // set video commands
  859. AVC_SET_WIDTH = 0xACD000,
  860. AVC_SET_HEIGHT,
  861. // set video encoding commands
  862. AVC_SET_FRAME_RATE = 0xACD800,
  863. AVC_SET_QUALITY,
  864. AVC_SET_HURRY_UP,
  865. // set audio commands
  866. AVC_SET_SAMPLE_RATE = 0xACE000,
  867. AVC_SET_CHANNELS,
  868. } avc_cmd_t;
  869. /**
  870. * \param handle allocated private structure by libavcodec
  871. * for initialization pass NULL - will be returned pout
  872. * user is supposed to know nothing about its structure
  873. * \param cmd type of operation to be performed
  874. * \param pint input parameter
  875. * \param pout output parameter
  876. *
  877. * \returns command status - eventually for query command it might return
  878. * integer resulting value
  879. */
  880. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  881. /* memory */
  882. void *av_malloc(int size);
  883. void *av_mallocz(int size);
  884. void av_free(void *ptr);
  885. void __av_freep(void **ptr);
  886. #define av_freep(p) __av_freep((void **)(p))
  887. #endif /* AVCODEC_H */