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.

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