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.

1058 lines
29KB

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