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.

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