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.

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