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.

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