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.

1007 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 4629
  7. #define LIBAVCODEC_BUILD_STR "4629"
  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. /**
  588. * idct algorithm, see FF_IDCT_* below
  589. * encoding: set by user
  590. * decoding: set by user
  591. */
  592. int idct_algo;
  593. #define FF_IDCT_AUTO 0
  594. #define FF_IDCT_INT 1
  595. #define FF_IDCT_SIMPLE 2
  596. #define FF_IDCT_SIMPLEMMX 3
  597. #define FF_IDCT_LIBMPEG2MMX 4
  598. #define FF_IDCT_PS2 5
  599. #define FF_IDCT_MLIB 6
  600. #define FF_IDCT_ARM 7
  601. //FIXME this should be reordered after kabis API is finished ...
  602. //TODO kill kabi
  603. /*
  604. Note: Below are located reserved fields for further usage
  605. It requires for ABI !!!
  606. If you'll perform some changes then borrow new space from these fields
  607. (void * can be safety replaced with struct * ;)
  608. P L E A S E ! ! !
  609. Note: use avcodec_alloc_context instead of malloc to allocate this,
  610. otherwise the ABI compatibility will be broken between versions
  611. IMPORTANT: Never change order of already declared fields!!!
  612. */
  613. //TODO: remove mess below
  614. unsigned long long int
  615. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  616. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11;
  617. float
  618. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  619. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  620. void
  621. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  622. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  623. unsigned long int
  624. ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5,
  625. ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12;
  626. unsigned short int
  627. us_res0,us_res1,us_res2,us_res3,us_res4,us_res5,
  628. us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
  629. unsigned char
  630. uc_res0,uc_res1,uc_res2,uc_res3,uc_res4,uc_res5,
  631. uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12;
  632. unsigned int
  633. ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5,ui_res6,ui_res7,ui_res8,ui_res9,
  634. ui_res10,ui_res11,ui_res12,ui_res13,ui_res14,ui_res15,ui_res16;
  635. } AVCodecContext;
  636. typedef struct AVCodec {
  637. char *name;
  638. int type;
  639. int id;
  640. int priv_data_size;
  641. int (*init)(AVCodecContext *);
  642. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  643. int (*close)(AVCodecContext *);
  644. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  645. UINT8 *buf, int buf_size);
  646. int capabilities;
  647. struct AVCodec *next;
  648. /*
  649. Note: Below are located reserved fields for further usage
  650. It requires for ABI !!!
  651. If you'll perform some changes then borrow new space from these fields
  652. (void * can be safety replaced with struct * ;)
  653. P L E A S E ! ! !
  654. IMPORTANT: Never change order of already declared fields!!!
  655. */
  656. unsigned long long int
  657. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  658. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11,ull_res12;
  659. float
  660. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  661. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  662. void
  663. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  664. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  665. } AVCodec;
  666. /* three components are given, that's all */
  667. typedef struct AVPicture {
  668. UINT8 *data[3];
  669. int linesize[3];
  670. } AVPicture;
  671. extern AVCodec ac3_encoder;
  672. extern AVCodec mp2_encoder;
  673. extern AVCodec mp3lame_encoder;
  674. extern AVCodec oggvorbis_encoder;
  675. extern AVCodec mpeg1video_encoder;
  676. extern AVCodec h263_encoder;
  677. extern AVCodec h263p_encoder;
  678. extern AVCodec rv10_encoder;
  679. extern AVCodec mjpeg_encoder;
  680. extern AVCodec mpeg4_encoder;
  681. extern AVCodec msmpeg4v1_encoder;
  682. extern AVCodec msmpeg4v2_encoder;
  683. extern AVCodec msmpeg4v3_encoder;
  684. extern AVCodec wmv1_encoder;
  685. extern AVCodec wmv2_encoder;
  686. extern AVCodec h263_decoder;
  687. extern AVCodec mpeg4_decoder;
  688. extern AVCodec msmpeg4v1_decoder;
  689. extern AVCodec msmpeg4v2_decoder;
  690. extern AVCodec msmpeg4v3_decoder;
  691. extern AVCodec wmv1_decoder;
  692. extern AVCodec wmv2_decoder;
  693. extern AVCodec mpeg_decoder;
  694. extern AVCodec h263i_decoder;
  695. extern AVCodec rv10_decoder;
  696. extern AVCodec svq1_decoder;
  697. extern AVCodec mjpeg_decoder;
  698. extern AVCodec mp2_decoder;
  699. extern AVCodec mp3_decoder;
  700. /* pcm codecs */
  701. #define PCM_CODEC(id, name) \
  702. extern AVCodec name ## _decoder; \
  703. extern AVCodec name ## _encoder;
  704. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  705. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  706. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  707. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  708. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  709. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  710. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  711. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  712. /* adpcm codecs */
  713. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  714. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  715. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  716. #undef PCM_CODEC
  717. /* dummy raw video codec */
  718. extern AVCodec rawvideo_codec;
  719. /* the following codecs use external GPL libs */
  720. extern AVCodec ac3_decoder;
  721. /* resample.c */
  722. struct ReSampleContext;
  723. typedef struct ReSampleContext ReSampleContext;
  724. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  725. int output_rate, int input_rate);
  726. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  727. void audio_resample_close(ReSampleContext *s);
  728. /* YUV420 format is assumed ! */
  729. struct ImgReSampleContext;
  730. typedef struct ImgReSampleContext ImgReSampleContext;
  731. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  732. int input_width, int input_height);
  733. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  734. int iwidth, int iheight,
  735. int topBand, int bottomBand,
  736. int leftBand, int rightBand);
  737. void img_resample(ImgReSampleContext *s,
  738. AVPicture *output, AVPicture *input);
  739. void img_resample_close(ImgReSampleContext *s);
  740. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  741. int pix_fmt, int width, int height);
  742. int avpicture_get_size(int pix_fmt, int width, int height);
  743. /* convert among pixel formats */
  744. int img_convert(AVPicture *dst, int dst_pix_fmt,
  745. AVPicture *src, int pix_fmt,
  746. int width, int height);
  747. /* deinterlace a picture */
  748. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  749. int pix_fmt, int width, int height);
  750. /* external high level API */
  751. extern AVCodec *first_avcodec;
  752. /* returns LIBAVCODEC_VERSION_INT constant */
  753. unsigned avcodec_version(void);
  754. /* returns LIBAVCODEC_BUILD constant */
  755. unsigned avcodec_build(void);
  756. void avcodec_init(void);
  757. void avcodec_set_bit_exact(void);
  758. void register_avcodec(AVCodec *format);
  759. AVCodec *avcodec_find_encoder(enum CodecID id);
  760. AVCodec *avcodec_find_encoder_by_name(const char *name);
  761. AVCodec *avcodec_find_decoder(enum CodecID id);
  762. AVCodec *avcodec_find_decoder_by_name(const char *name);
  763. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  764. AVCodecContext *avcodec_alloc_context(void);
  765. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  766. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  767. int *frame_size_ptr,
  768. UINT8 *buf, int buf_size);
  769. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  770. int *got_picture_ptr,
  771. UINT8 *buf, int buf_size);
  772. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  773. int *data_size_ptr,
  774. UINT8 *buf, int buf_size);
  775. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  776. const short *samples);
  777. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  778. const AVPicture *pict);
  779. int avcodec_close(AVCodecContext *avctx);
  780. void avcodec_register_all(void);
  781. void avcodec_flush_buffers(AVCodecContext *avctx);
  782. #ifdef FF_POSTPROCESS
  783. extern int quant_store[MBR+1][MBC+1]; // [Review]
  784. #endif
  785. /**
  786. * Interface for 0.5.0 version
  787. *
  788. * do not even think about it's usage for this moment
  789. */
  790. typedef struct {
  791. // compressed size used from given memory buffer
  792. int size;
  793. /// I/P/B frame type
  794. int frame_type;
  795. } avc_enc_result_t;
  796. /**
  797. * Commands
  798. * order can't be changed - once it was defined
  799. */
  800. typedef enum {
  801. // general commands
  802. AVC_OPEN_BY_NAME = 0xACA000,
  803. AVC_OPEN_BY_CODEC_ID,
  804. AVC_OPEN_BY_FOURCC,
  805. AVC_CLOSE,
  806. AVC_FLUSH,
  807. // pin - struct { uint8_t* src, uint_t src_size }
  808. // pout - struct { AVPicture* img, consumed_bytes,
  809. AVC_DECODE,
  810. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  811. // pout - uint_t used_from_dest_size
  812. AVC_ENCODE,
  813. // query/get video commands
  814. AVC_GET_VERSION = 0xACB000,
  815. AVC_GET_WIDTH,
  816. AVC_GET_HEIGHT,
  817. AVC_GET_DELAY,
  818. AVC_GET_QUANT_TABLE,
  819. // ...
  820. // query/get audio commands
  821. AVC_GET_FRAME_SIZE = 0xABC000,
  822. // maybe define some simple structure which
  823. // might be passed to the user - but they can't
  824. // contain any codec specific parts and these
  825. // calls are usualy necessary only few times
  826. // set video commands
  827. AVC_SET_WIDTH = 0xACD000,
  828. AVC_SET_HEIGHT,
  829. // set video encoding commands
  830. AVC_SET_FRAME_RATE = 0xACD800,
  831. AVC_SET_QUALITY,
  832. AVC_SET_HURRY_UP,
  833. // set audio commands
  834. AVC_SET_SAMPLE_RATE = 0xACE000,
  835. AVC_SET_CHANNELS,
  836. } avc_cmd_t;
  837. /**
  838. * \param handle allocated private structure by libavcodec
  839. * for initialization pass NULL - will be returned pout
  840. * user is supposed to know nothing about its structure
  841. * \param cmd type of operation to be performed
  842. * \param pint input parameter
  843. * \param pout output parameter
  844. *
  845. * \returns command status - eventually for query command it might return
  846. * integer resulting value
  847. */
  848. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  849. /* memory */
  850. void *av_malloc(int size);
  851. void *av_mallocz(int size);
  852. void av_free(void *ptr);
  853. void __av_freep(void **ptr);
  854. #define av_freep(p) __av_freep((void **)(p))
  855. #endif /* AVCODEC_H */