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.

1012 lines
28KB

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