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.

941 lines
27KB

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