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.

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