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.

1042 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_FAKE_SCALABILITY 16 //autodetection should work 100%
  370. /**
  371. * encoding: set by user
  372. * decoding: unused
  373. */
  374. int luma_elim_threshold;
  375. /**
  376. * encoding: set by user
  377. * decoding: unused
  378. */
  379. int chroma_elim_threshold;
  380. /**
  381. * strictly follow the std (MPEG4, ...)
  382. * encoding: set by user
  383. * decoding: unused
  384. */
  385. int strict_std_compliance;
  386. /**
  387. * qscale offset between ip and b frames
  388. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  389. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  390. * encoding: set by user.
  391. * decoding: unused
  392. */
  393. float b_quant_offset;
  394. /**
  395. * error resilience {-1,0,1} higher values will detect more errors but may missdetect
  396. * some more or less valid parts as errors
  397. * encoding: unused
  398. * decoding: set by user
  399. */
  400. int error_resilience;
  401. #ifndef MBC
  402. #define MBC 128
  403. #define MBR 96
  404. #endif
  405. #define QP_TYPE int //FIXME note xxx this might be changed to int8_t
  406. QP_TYPE *quant_store; /* field for communicating with external postprocessing */
  407. unsigned qstride;
  408. /**
  409. * buffer, where the next picture should be decoded into
  410. * encoding: unused
  411. * decoding: set by user in get_buffer_callback to a buffer into which the next part
  412. * of the bitstream will be decoded, and set by lavc at end of frame to the
  413. * next frame which needs to be displayed
  414. */
  415. uint8_t *dr_buffer[3];
  416. /**
  417. * stride of the luminance part of the dr buffer
  418. * encoding: unused
  419. * decoding: set by user
  420. */
  421. int dr_stride;
  422. /**
  423. * same behavior as dr_buffer, just for some private data of the user
  424. * encoding: unused
  425. * decoding: set by user in get_buffer_callback, and set by lavc at end of frame
  426. */
  427. void *dr_opaque_frame;
  428. /**
  429. * called at the beginning of each frame to get a buffer for it
  430. * encoding: unused
  431. * decoding: set by user
  432. */
  433. void (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type);
  434. /**
  435. * is 1 if the decoded stream contains b frames, 0 otherwise
  436. * encoding: unused
  437. * decoding: set by lavc
  438. */
  439. int has_b_frames;
  440. /**
  441. * stride of the chrominance part of the dr buffer
  442. * encoding: unused
  443. * decoding: set by user
  444. */
  445. int dr_uvstride;
  446. /**
  447. * number of dr buffers
  448. * encoding: unused
  449. * decoding: set by user
  450. */
  451. int dr_ip_buffer_count;
  452. int block_align; /* currently only for adpcm codec in wav/avi */
  453. int parse_only; /* decoding only: if true, only parsing is done
  454. (function avcodec_parse_frame()). The frame
  455. data is returned. Only MPEG codecs support this now. */
  456. /**
  457. * 0-> h263 quant 1-> mpeg quant
  458. * encoding: set by user.
  459. * decoding: unused
  460. */
  461. int mpeg_quant;
  462. /**
  463. * pass1 encoding statistics output buffer
  464. * encoding: set by lavc
  465. * decoding: unused
  466. */
  467. char *stats_out; /* encoding statistics output buffer */
  468. /**
  469. * pass2 encoding statistics input buffer.
  470. * concatenated stuff from stats_out of pass1 should be placed here
  471. * encoding: allocated/set/freed by user
  472. * decoding: unused
  473. */
  474. char *stats_in;
  475. /**
  476. * ratecontrol qmin qmax limiting method
  477. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  478. * encoding: set by user.
  479. * decoding: unused
  480. */
  481. float rc_qsquish;
  482. float rc_qmod_amp;
  483. int rc_qmod_freq;
  484. /**
  485. * ratecontrol override, see RcOverride
  486. * encoding: allocated/set/freed by user.
  487. * decoding: unused
  488. */
  489. RcOverride *rc_override;
  490. int rc_override_count;
  491. /**
  492. * rate control equation
  493. * encoding: set by user
  494. * decoding: unused
  495. */
  496. char *rc_eq;
  497. /**
  498. * maximum bitrate
  499. * encoding: set by user.
  500. * decoding: unused
  501. */
  502. int rc_max_rate;
  503. /**
  504. * minimum bitrate
  505. * encoding: set by user.
  506. * decoding: unused
  507. */
  508. int rc_min_rate;
  509. /**
  510. * decoder bitstream buffer size
  511. * encoding: set by user.
  512. * decoding: unused
  513. */
  514. int rc_buffer_size;
  515. float rc_buffer_aggressivity;
  516. /**
  517. * qscale factor between p and i frames
  518. * encoding: set by user.
  519. * decoding: unused
  520. */
  521. float i_quant_factor;
  522. /**
  523. * qscale offset between p and i frames
  524. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  525. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  526. * encoding: set by user.
  527. * decoding: unused
  528. */
  529. float i_quant_offset;
  530. /**
  531. * initial complexity for pass1 ratecontrol
  532. * encoding: set by user.
  533. * decoding: unused
  534. */
  535. float rc_initial_cplx;
  536. /**
  537. * custom aspect ratio, used if aspect_info==FF_ASPECT_EXTENDED
  538. * encoding: set by user.
  539. * decoding: set by lavc.
  540. */
  541. int aspected_width;
  542. int aspected_height;
  543. /**
  544. * dct algorithm, see FF_DCT_* below
  545. * encoding: set by user
  546. * decoding: unused
  547. */
  548. int dct_algo;
  549. #define FF_DCT_AUTO 0
  550. #define FF_DCT_FASTINT 1
  551. #define FF_DCT_INT 2
  552. #define FF_DCT_MMX 3
  553. #define FF_DCT_MLIB 4
  554. /**
  555. * presentation timestamp in micro seconds (time when frame should be shown to user)
  556. * if 0 then the frame_rate will be used as reference
  557. * encoding: set by user
  558. * decoding; set by lavc
  559. */
  560. long long int pts;
  561. /**
  562. * luminance masking (0-> disabled)
  563. * encoding: set by user
  564. * decoding: unused
  565. */
  566. float lumi_masking;
  567. /**
  568. * temporary complexity masking (0-> disabled)
  569. * encoding: set by user
  570. * decoding: unused
  571. */
  572. float temporal_cplx_masking;
  573. /**
  574. * spatial complexity masking (0-> disabled)
  575. * encoding: set by user
  576. * decoding: unused
  577. */
  578. float spatial_cplx_masking;
  579. /**
  580. * p block masking (0-> disabled)
  581. * encoding: set by user
  582. * decoding: unused
  583. */
  584. float p_masking;
  585. /**
  586. * darkness masking (0-> disabled)
  587. * encoding: set by user
  588. * decoding: unused
  589. */
  590. float dark_masking;
  591. /**
  592. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
  593. * this is used to workaround some encoder bugs
  594. * encoding: unused
  595. * decoding: set by user, will be converted to upper case by lavc during init
  596. */
  597. int fourcc;
  598. /**
  599. * idct algorithm, see FF_IDCT_* below
  600. * encoding: set by user
  601. * decoding: set by user
  602. */
  603. int idct_algo;
  604. #define FF_IDCT_AUTO 0
  605. #define FF_IDCT_INT 1
  606. #define FF_IDCT_SIMPLE 2
  607. #define FF_IDCT_SIMPLEMMX 3
  608. #define FF_IDCT_LIBMPEG2MMX 4
  609. #define FF_IDCT_PS2 5
  610. #define FF_IDCT_MLIB 6
  611. #define FF_IDCT_ARM 7
  612. /**
  613. * slice count
  614. * encoding: set by lavc
  615. * decoding: set by user (or 0)
  616. */
  617. int slice_count;
  618. /**
  619. * slice offsets in the frame in bytes
  620. * encoding: set/allocated by lavc
  621. * decoding: set/allocated by user (or NULL)
  622. */
  623. int *slice_offset;
  624. /**
  625. * error concealment flags
  626. * encoding: unused
  627. * decoding: set by user
  628. */
  629. int error_concealment;
  630. #define FF_EC_GUESS_MVS 1
  631. #define FF_EC_DEBLOCK 2
  632. //FIXME this should be reordered after kabis API is finished ...
  633. //TODO kill kabi
  634. /*
  635. Note: Below are located reserved fields for further usage
  636. It requires for ABI !!!
  637. If you'll perform some changes then borrow new space from these fields
  638. (void * can be safety replaced with struct * ;)
  639. P L E A S E ! ! !
  640. Note: use avcodec_alloc_context instead of malloc to allocate this,
  641. otherwise the ABI compatibility will be broken between versions
  642. IMPORTANT: Never change order of already declared fields!!!
  643. */
  644. //TODO: remove mess below
  645. unsigned long long int
  646. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  647. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11;
  648. float
  649. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  650. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  651. void
  652. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  653. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  654. unsigned long int
  655. ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5,
  656. ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12;
  657. unsigned short int
  658. us_res0,us_res1,us_res2,us_res3,us_res4,us_res5,
  659. us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
  660. unsigned char
  661. uc_res0,uc_res1,uc_res2,uc_res3,uc_res4,uc_res5,
  662. uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12;
  663. unsigned int
  664. ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5,ui_res6,ui_res7,ui_res8,ui_res9,
  665. ui_res10,ui_res11,ui_res12,ui_res13,ui_res14,ui_res15,ui_res16;
  666. } AVCodecContext;
  667. typedef struct AVCodec {
  668. char *name;
  669. int type;
  670. int id;
  671. int priv_data_size;
  672. int (*init)(AVCodecContext *);
  673. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  674. int (*close)(AVCodecContext *);
  675. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  676. UINT8 *buf, int buf_size);
  677. int capabilities;
  678. struct AVCodec *next;
  679. /*
  680. Note: Below are located reserved fields for further usage
  681. It requires for ABI !!!
  682. If you'll perform some changes then borrow new space from these fields
  683. (void * can be safety replaced with struct * ;)
  684. P L E A S E ! ! !
  685. IMPORTANT: Never change order of already declared fields!!!
  686. */
  687. unsigned long long int
  688. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  689. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11,ull_res12;
  690. float
  691. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  692. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  693. void
  694. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  695. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  696. } AVCodec;
  697. /* three components are given, that's all */
  698. typedef struct AVPicture {
  699. UINT8 *data[3];
  700. int linesize[3];
  701. } AVPicture;
  702. extern AVCodec ac3_encoder;
  703. extern AVCodec mp2_encoder;
  704. extern AVCodec mp3lame_encoder;
  705. extern AVCodec oggvorbis_encoder;
  706. extern AVCodec mpeg1video_encoder;
  707. extern AVCodec h263_encoder;
  708. extern AVCodec h263p_encoder;
  709. extern AVCodec rv10_encoder;
  710. extern AVCodec mjpeg_encoder;
  711. extern AVCodec mpeg4_encoder;
  712. extern AVCodec msmpeg4v1_encoder;
  713. extern AVCodec msmpeg4v2_encoder;
  714. extern AVCodec msmpeg4v3_encoder;
  715. extern AVCodec wmv1_encoder;
  716. extern AVCodec wmv2_encoder;
  717. extern AVCodec h263_decoder;
  718. extern AVCodec mpeg4_decoder;
  719. extern AVCodec msmpeg4v1_decoder;
  720. extern AVCodec msmpeg4v2_decoder;
  721. extern AVCodec msmpeg4v3_decoder;
  722. extern AVCodec wmv1_decoder;
  723. extern AVCodec wmv2_decoder;
  724. extern AVCodec mpeg_decoder;
  725. extern AVCodec h263i_decoder;
  726. extern AVCodec rv10_decoder;
  727. extern AVCodec svq1_decoder;
  728. extern AVCodec dvvideo_decoder;
  729. extern AVCodec dvaudio_decoder;
  730. extern AVCodec mjpeg_decoder;
  731. extern AVCodec mp2_decoder;
  732. extern AVCodec mp3_decoder;
  733. /* pcm codecs */
  734. #define PCM_CODEC(id, name) \
  735. extern AVCodec name ## _decoder; \
  736. extern AVCodec name ## _encoder;
  737. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  738. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  739. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  740. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  741. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  742. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  743. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  744. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  745. /* adpcm codecs */
  746. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  747. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  748. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  749. #undef PCM_CODEC
  750. /* dummy raw video codec */
  751. extern AVCodec rawvideo_codec;
  752. /* the following codecs use external GPL libs */
  753. extern AVCodec ac3_decoder;
  754. /* resample.c */
  755. struct ReSampleContext;
  756. typedef struct ReSampleContext ReSampleContext;
  757. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  758. int output_rate, int input_rate);
  759. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  760. void audio_resample_close(ReSampleContext *s);
  761. /* YUV420 format is assumed ! */
  762. struct ImgReSampleContext;
  763. typedef struct ImgReSampleContext ImgReSampleContext;
  764. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  765. int input_width, int input_height);
  766. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  767. int iwidth, int iheight,
  768. int topBand, int bottomBand,
  769. int leftBand, int rightBand);
  770. void img_resample(ImgReSampleContext *s,
  771. AVPicture *output, AVPicture *input);
  772. void img_resample_close(ImgReSampleContext *s);
  773. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  774. int pix_fmt, int width, int height);
  775. int avpicture_get_size(int pix_fmt, int width, int height);
  776. /* convert among pixel formats */
  777. int img_convert(AVPicture *dst, int dst_pix_fmt,
  778. AVPicture *src, int pix_fmt,
  779. int width, int height);
  780. /* deinterlace a picture */
  781. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  782. int pix_fmt, int width, int height);
  783. /* external high level API */
  784. extern AVCodec *first_avcodec;
  785. /* returns LIBAVCODEC_VERSION_INT constant */
  786. unsigned avcodec_version(void);
  787. /* returns LIBAVCODEC_BUILD constant */
  788. unsigned avcodec_build(void);
  789. void avcodec_init(void);
  790. void avcodec_set_bit_exact(void);
  791. void register_avcodec(AVCodec *format);
  792. AVCodec *avcodec_find_encoder(enum CodecID id);
  793. AVCodec *avcodec_find_encoder_by_name(const char *name);
  794. AVCodec *avcodec_find_decoder(enum CodecID id);
  795. AVCodec *avcodec_find_decoder_by_name(const char *name);
  796. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  797. AVCodecContext *avcodec_alloc_context(void);
  798. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  799. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  800. int *frame_size_ptr,
  801. UINT8 *buf, int buf_size);
  802. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  803. int *got_picture_ptr,
  804. UINT8 *buf, int buf_size);
  805. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  806. int *data_size_ptr,
  807. UINT8 *buf, int buf_size);
  808. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  809. const short *samples);
  810. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  811. const AVPicture *pict);
  812. int avcodec_close(AVCodecContext *avctx);
  813. void avcodec_register_all(void);
  814. void avcodec_flush_buffers(AVCodecContext *avctx);
  815. #ifdef FF_POSTPROCESS
  816. extern int quant_store[MBR+1][MBC+1]; // [Review]
  817. #endif
  818. /**
  819. * Interface for 0.5.0 version
  820. *
  821. * do not even think about it's usage for this moment
  822. */
  823. typedef struct {
  824. // compressed size used from given memory buffer
  825. int size;
  826. /// I/P/B frame type
  827. int frame_type;
  828. } avc_enc_result_t;
  829. /**
  830. * Commands
  831. * order can't be changed - once it was defined
  832. */
  833. typedef enum {
  834. // general commands
  835. AVC_OPEN_BY_NAME = 0xACA000,
  836. AVC_OPEN_BY_CODEC_ID,
  837. AVC_OPEN_BY_FOURCC,
  838. AVC_CLOSE,
  839. AVC_FLUSH,
  840. // pin - struct { uint8_t* src, uint_t src_size }
  841. // pout - struct { AVPicture* img, consumed_bytes,
  842. AVC_DECODE,
  843. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  844. // pout - uint_t used_from_dest_size
  845. AVC_ENCODE,
  846. // query/get video commands
  847. AVC_GET_VERSION = 0xACB000,
  848. AVC_GET_WIDTH,
  849. AVC_GET_HEIGHT,
  850. AVC_GET_DELAY,
  851. AVC_GET_QUANT_TABLE,
  852. // ...
  853. // query/get audio commands
  854. AVC_GET_FRAME_SIZE = 0xABC000,
  855. // maybe define some simple structure which
  856. // might be passed to the user - but they can't
  857. // contain any codec specific parts and these
  858. // calls are usualy necessary only few times
  859. // set video commands
  860. AVC_SET_WIDTH = 0xACD000,
  861. AVC_SET_HEIGHT,
  862. // set video encoding commands
  863. AVC_SET_FRAME_RATE = 0xACD800,
  864. AVC_SET_QUALITY,
  865. AVC_SET_HURRY_UP,
  866. // set audio commands
  867. AVC_SET_SAMPLE_RATE = 0xACE000,
  868. AVC_SET_CHANNELS,
  869. } avc_cmd_t;
  870. /**
  871. * \param handle allocated private structure by libavcodec
  872. * for initialization pass NULL - will be returned pout
  873. * user is supposed to know nothing about its structure
  874. * \param cmd type of operation to be performed
  875. * \param pint input parameter
  876. * \param pout output parameter
  877. *
  878. * \returns command status - eventually for query command it might return
  879. * integer resulting value
  880. */
  881. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  882. /* memory */
  883. void *av_malloc(int size);
  884. void *av_mallocz(int size);
  885. void av_free(void *ptr);
  886. void __av_freep(void **ptr);
  887. #define av_freep(p) __av_freep((void **)(p))
  888. #endif /* AVCODEC_H */