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.

1027 lines
28KB

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