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.

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