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.

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