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.

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