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.

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