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.

1063 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 4640
  7. #define LIBAVCODEC_BUILD_STR "4640"
  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. #define CODEC_FLAG_ALT_SCAN 0x00100000 /* use alternate scan */
  131. /* codec capabilities */
  132. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 /* decoder can use draw_horiz_band callback */
  133. #define CODEC_CAP_DR1 0x0002 /* direct rendering method 1 */
  134. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  135. used */
  136. #define CODEC_CAP_PARSE_ONLY 0x0004
  137. #define CODEC_CAP_TRUNCATED 0x0008
  138. #define FRAME_RATE_BASE 10000
  139. typedef struct AVCodecContext {
  140. /**
  141. * the average bitrate
  142. * encoding: set by user. unused for constant quantizer encoding
  143. * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  144. */
  145. int bit_rate;
  146. /**
  147. * number of bits the bitstream is allowed to diverge from the reference
  148. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  149. * encoding: set by user. unused for constant quantizer encoding
  150. * decoding: unused
  151. */
  152. int bit_rate_tolerance;
  153. /**
  154. * CODEC_FLAG_*
  155. * encoding: set by user.
  156. * decoding: set by user.
  157. */
  158. int flags;
  159. /**
  160. * some codecs needs additionnal format info. It is stored here
  161. * encoding: set by user.
  162. * decoding: set by lavc. (FIXME is this ok?)
  163. */
  164. int sub_id;
  165. /**
  166. * motion estimation algorithm used for video coding
  167. * encoding: set by user.
  168. * decoding: unused
  169. */
  170. int me_method;
  171. /**
  172. * some codecs need / can use extra-data like huffman tables
  173. * mjpeg: huffman tables
  174. * rv10: additional flags
  175. * mpeg4: global headers (they can be in the bitstream or here)
  176. * encoding: set/allocated/freed by lavc.
  177. * decoding: set/allocated/freed by user.
  178. */
  179. void *extradata;
  180. int extradata_size;
  181. /* video only */
  182. /**
  183. * frames per sec multiplied by FRAME_RATE_BASE
  184. * for variable fps this is the precission, so if the timestamps
  185. * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
  186. * encoding: set by user
  187. * decoding: set by lavc. 0 or the frame_rate if available
  188. */
  189. int frame_rate;
  190. /**
  191. * encoding: set by user.
  192. * decoding: set by user, some codecs might override / change it during playback
  193. */
  194. int width, height;
  195. /**
  196. * Obsolete, will be removed
  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. * Obsolete, will be removed
  559. */
  560. int aspected_width;
  561. int aspected_height;
  562. /**
  563. * dct algorithm, see FF_DCT_* below
  564. * encoding: set by user
  565. * decoding: unused
  566. */
  567. int dct_algo;
  568. #define FF_DCT_AUTO 0
  569. #define FF_DCT_FASTINT 1
  570. #define FF_DCT_INT 2
  571. #define FF_DCT_MMX 3
  572. #define FF_DCT_MLIB 4
  573. #define FF_DCT_ALTIVEC 5
  574. /**
  575. * presentation timestamp in micro seconds (time when frame should be shown to user)
  576. * if 0 then the frame_rate will be used as reference
  577. * encoding: set by user
  578. * decoding; set by lavc
  579. */
  580. long long int pts;
  581. /**
  582. * luminance masking (0-> disabled)
  583. * encoding: set by user
  584. * decoding: unused
  585. */
  586. float lumi_masking;
  587. /**
  588. * temporary complexity masking (0-> disabled)
  589. * encoding: set by user
  590. * decoding: unused
  591. */
  592. float temporal_cplx_masking;
  593. /**
  594. * spatial complexity masking (0-> disabled)
  595. * encoding: set by user
  596. * decoding: unused
  597. */
  598. float spatial_cplx_masking;
  599. /**
  600. * p block masking (0-> disabled)
  601. * encoding: set by user
  602. * decoding: unused
  603. */
  604. float p_masking;
  605. /**
  606. * darkness masking (0-> disabled)
  607. * encoding: set by user
  608. * decoding: unused
  609. */
  610. float dark_masking;
  611. /**
  612. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
  613. * this is used to workaround some encoder bugs
  614. * encoding: unused
  615. * decoding: set by user, will be converted to upper case by lavc during init
  616. */
  617. int fourcc;
  618. /**
  619. * idct algorithm, see FF_IDCT_* below
  620. * encoding: set by user
  621. * decoding: set by user
  622. */
  623. int idct_algo;
  624. #define FF_IDCT_AUTO 0
  625. #define FF_IDCT_INT 1
  626. #define FF_IDCT_SIMPLE 2
  627. #define FF_IDCT_SIMPLEMMX 3
  628. #define FF_IDCT_LIBMPEG2MMX 4
  629. #define FF_IDCT_PS2 5
  630. #define FF_IDCT_MLIB 6
  631. #define FF_IDCT_ARM 7
  632. #define FF_IDCT_ALTIVEC 8
  633. /**
  634. * slice count
  635. * encoding: set by lavc
  636. * decoding: set by user (or 0)
  637. */
  638. int slice_count;
  639. /**
  640. * slice offsets in the frame in bytes
  641. * encoding: set/allocated by lavc
  642. * decoding: set/allocated by user (or NULL)
  643. */
  644. int *slice_offset;
  645. /**
  646. * error concealment flags
  647. * encoding: unused
  648. * decoding: set by user
  649. */
  650. int error_concealment;
  651. #define FF_EC_GUESS_MVS 1
  652. #define FF_EC_DEBLOCK 2
  653. /**
  654. * QP table of the currently decoded frame
  655. * encoding; unused
  656. * decoding: set by lavc
  657. */
  658. int8_t *current_qscale_table;
  659. /**
  660. * QP table of the currently displayed frame
  661. * encoding; unused
  662. * decoding: set by lavc
  663. */
  664. int8_t *display_qscale_table;
  665. /**
  666. * force specific pict_type.
  667. * encoding; set by user (I/P/B_TYPE)
  668. * decoding: unused
  669. */
  670. int force_type;
  671. /**
  672. * dsp_mask could be used to disable unwanted
  673. * CPU features (i.e. MMX, SSE. ...)
  674. */
  675. unsigned dsp_mask;
  676. /**
  677. * bits per sample/pixel from the demuxer (needed for huffyuv)
  678. * encoding; set by lavc
  679. * decoding: set by user
  680. */
  681. int bits_per_sample;
  682. /**
  683. * prediction method (needed for huffyuv)
  684. * encoding; set by user
  685. * decoding: unused
  686. */
  687. int prediction_method;
  688. #define FF_PRED_LEFT 0
  689. #define FF_PRED_PLANE 1
  690. #define FF_PRED_MEDIAN 2
  691. /**
  692. * aspect ratio. (0 if unknown)
  693. * encoding: set by user.
  694. * decoding: set by lavc.
  695. */
  696. float aspect_ratio;
  697. } AVCodecContext;
  698. typedef struct AVCodec {
  699. const char *name;
  700. int type;
  701. int id;
  702. int priv_data_size;
  703. int (*init)(AVCodecContext *);
  704. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  705. int (*close)(AVCodecContext *);
  706. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  707. UINT8 *buf, int buf_size);
  708. int capabilities;
  709. struct AVCodec *next;
  710. } AVCodec;
  711. /**
  712. * four components are given, that's all.
  713. * the last component is alpha
  714. */
  715. typedef struct AVPicture {
  716. UINT8 *data[4];
  717. int linesize[4];
  718. } AVPicture;
  719. extern AVCodec ac3_encoder;
  720. extern AVCodec mp2_encoder;
  721. extern AVCodec mp3lame_encoder;
  722. extern AVCodec oggvorbis_encoder;
  723. extern AVCodec mpeg1video_encoder;
  724. extern AVCodec h263_encoder;
  725. extern AVCodec h263p_encoder;
  726. extern AVCodec rv10_encoder;
  727. extern AVCodec mjpeg_encoder;
  728. extern AVCodec mpeg4_encoder;
  729. extern AVCodec msmpeg4v1_encoder;
  730. extern AVCodec msmpeg4v2_encoder;
  731. extern AVCodec msmpeg4v3_encoder;
  732. extern AVCodec wmv1_encoder;
  733. extern AVCodec wmv2_encoder;
  734. extern AVCodec huffyuv_encoder;
  735. extern AVCodec h263_decoder;
  736. extern AVCodec mpeg4_decoder;
  737. extern AVCodec msmpeg4v1_decoder;
  738. extern AVCodec msmpeg4v2_decoder;
  739. extern AVCodec msmpeg4v3_decoder;
  740. extern AVCodec wmv1_decoder;
  741. extern AVCodec wmv2_decoder;
  742. extern AVCodec mpeg_decoder;
  743. extern AVCodec h263i_decoder;
  744. extern AVCodec rv10_decoder;
  745. extern AVCodec svq1_decoder;
  746. extern AVCodec dvvideo_decoder;
  747. extern AVCodec dvaudio_decoder;
  748. extern AVCodec wmav1_decoder;
  749. extern AVCodec wmav2_decoder;
  750. extern AVCodec mjpeg_decoder;
  751. extern AVCodec mp2_decoder;
  752. extern AVCodec mp3_decoder;
  753. extern AVCodec mace3_decoder;
  754. extern AVCodec mace6_decoder;
  755. extern AVCodec huffyuv_decoder;
  756. /* pcm codecs */
  757. #define PCM_CODEC(id, name) \
  758. extern AVCodec name ## _decoder; \
  759. extern AVCodec name ## _encoder
  760. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  761. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  762. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  763. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  764. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  765. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  766. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  767. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  768. /* adpcm codecs */
  769. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  770. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  771. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  772. #undef PCM_CODEC
  773. /* dummy raw video codec */
  774. extern AVCodec rawvideo_codec;
  775. /* the following codecs use external GPL libs */
  776. extern AVCodec ac3_decoder;
  777. /* resample.c */
  778. struct ReSampleContext;
  779. typedef struct ReSampleContext ReSampleContext;
  780. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  781. int output_rate, int input_rate);
  782. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  783. void audio_resample_close(ReSampleContext *s);
  784. /* YUV420 format is assumed ! */
  785. struct ImgReSampleContext;
  786. typedef struct ImgReSampleContext ImgReSampleContext;
  787. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  788. int input_width, int input_height);
  789. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  790. int iwidth, int iheight,
  791. int topBand, int bottomBand,
  792. int leftBand, int rightBand);
  793. void img_resample(ImgReSampleContext *s,
  794. AVPicture *output, AVPicture *input);
  795. void img_resample_close(ImgReSampleContext *s);
  796. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  797. int pix_fmt, int width, int height);
  798. int avpicture_get_size(int pix_fmt, int width, int height);
  799. /* convert among pixel formats */
  800. int img_convert(AVPicture *dst, int dst_pix_fmt,
  801. AVPicture *src, int pix_fmt,
  802. int width, int height);
  803. /* deinterlace a picture */
  804. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  805. int pix_fmt, int width, int height);
  806. /* external high level API */
  807. extern AVCodec *first_avcodec;
  808. /* returns LIBAVCODEC_VERSION_INT constant */
  809. unsigned avcodec_version(void);
  810. /* returns LIBAVCODEC_BUILD constant */
  811. unsigned avcodec_build(void);
  812. void avcodec_init(void);
  813. void avcodec_set_bit_exact(void);
  814. void register_avcodec(AVCodec *format);
  815. AVCodec *avcodec_find_encoder(enum CodecID id);
  816. AVCodec *avcodec_find_encoder_by_name(const char *name);
  817. AVCodec *avcodec_find_decoder(enum CodecID id);
  818. AVCodec *avcodec_find_decoder_by_name(const char *name);
  819. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  820. AVCodecContext *avcodec_alloc_context(void);
  821. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  822. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  823. int *frame_size_ptr,
  824. UINT8 *buf, int buf_size);
  825. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  826. int *got_picture_ptr,
  827. UINT8 *buf, int buf_size);
  828. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  829. int *data_size_ptr,
  830. UINT8 *buf, int buf_size);
  831. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  832. const short *samples);
  833. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  834. const AVPicture *pict);
  835. int avcodec_close(AVCodecContext *avctx);
  836. void avcodec_register_all(void);
  837. void avcodec_flush_buffers(AVCodecContext *avctx);
  838. /**
  839. * Interface for 0.5.0 version
  840. *
  841. * do not even think about it's usage for this moment
  842. */
  843. typedef struct {
  844. // compressed size used from given memory buffer
  845. int size;
  846. /// I/P/B frame type
  847. int frame_type;
  848. } avc_enc_result_t;
  849. /**
  850. * Commands
  851. * order can't be changed - once it was defined
  852. */
  853. typedef enum {
  854. // general commands
  855. AVC_OPEN_BY_NAME = 0xACA000,
  856. AVC_OPEN_BY_CODEC_ID,
  857. AVC_OPEN_BY_FOURCC,
  858. AVC_CLOSE,
  859. AVC_FLUSH,
  860. // pin - struct { uint8_t* src, uint_t src_size }
  861. // pout - struct { AVPicture* img, consumed_bytes,
  862. AVC_DECODE,
  863. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  864. // pout - uint_t used_from_dest_size
  865. AVC_ENCODE,
  866. // query/get video commands
  867. AVC_GET_VERSION = 0xACB000,
  868. AVC_GET_WIDTH,
  869. AVC_GET_HEIGHT,
  870. AVC_GET_DELAY,
  871. AVC_GET_QUANT_TABLE,
  872. // ...
  873. // query/get audio commands
  874. AVC_GET_FRAME_SIZE = 0xABC000,
  875. // maybe define some simple structure which
  876. // might be passed to the user - but they can't
  877. // contain any codec specific parts and these
  878. // calls are usualy necessary only few times
  879. // set video commands
  880. AVC_SET_WIDTH = 0xACD000,
  881. AVC_SET_HEIGHT,
  882. // set video encoding commands
  883. AVC_SET_FRAME_RATE = 0xACD800,
  884. AVC_SET_QUALITY,
  885. AVC_SET_HURRY_UP,
  886. // set audio commands
  887. AVC_SET_SAMPLE_RATE = 0xACE000,
  888. AVC_SET_CHANNELS,
  889. } avc_cmd_t;
  890. /**
  891. * \param handle allocated private structure by libavcodec
  892. * for initialization pass NULL - will be returned pout
  893. * user is supposed to know nothing about its structure
  894. * \param cmd type of operation to be performed
  895. * \param pint input parameter
  896. * \param pout output parameter
  897. *
  898. * \returns command status - eventually for query command it might return
  899. * integer resulting value
  900. */
  901. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  902. /* memory */
  903. void *av_malloc(unsigned int size);
  904. void *av_mallocz(unsigned int size);
  905. void av_free(void *ptr);
  906. void __av_freep(void **ptr);
  907. #define av_freep(p) __av_freep((void **)(p))
  908. #endif /* AVCODEC_H */