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.

937 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. * encoding: set by user.
  372. * decoding: unused
  373. */
  374. float b_quant_offset;
  375. /**
  376. * error resilience {-1,0,1} higher values will detect more errors but may missdetect
  377. * some more or less valid parts as errors
  378. * encoding: unused
  379. * decoding: set by user
  380. */
  381. int error_resilience;
  382. #ifndef MBC
  383. #define MBC 128
  384. #define MBR 96
  385. #endif
  386. #define QP_TYPE int //FIXME note xxx this might be changed to int8_t
  387. QP_TYPE *quant_store; /* field for communicating with external postprocessing */
  388. unsigned qstride;
  389. /**
  390. * buffer, where the next picture should be decoded into
  391. * encoding: unused
  392. * decoding: set by user in get_buffer_callback to a buffer into which the next part
  393. * of the bitstream will be decoded, and set by lavc at end of frame to the
  394. * next frame which needs to be displayed
  395. */
  396. uint8_t *dr_buffer[3];
  397. /**
  398. * stride of the luminance part of the dr buffer
  399. * encoding: unused
  400. * decoding: set by user
  401. */
  402. int dr_stride;
  403. /**
  404. * same behavior as dr_buffer, just for some private data of the user
  405. * encoding: unused
  406. * decoding: set by user in get_buffer_callback, and set by lavc at end of frame
  407. */
  408. void *dr_opaque_frame;
  409. /**
  410. * called at the beginning of each frame to get a buffer for it
  411. * encoding: unused
  412. * decoding: set by user
  413. */
  414. void (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type);
  415. /**
  416. * is 1 if the decoded stream contains b frames, 0 otherwise
  417. * encoding: unused
  418. * decoding: set by lavc
  419. */
  420. int has_b_frames;
  421. /**
  422. * stride of the chrominance part of the dr buffer
  423. * encoding: unused
  424. * decoding: set by user
  425. */
  426. int dr_uvstride;
  427. /**
  428. * number of dr buffers
  429. * encoding: unused
  430. * decoding: set by user
  431. */
  432. int dr_ip_buffer_count;
  433. int block_align; /* currently only for adpcm codec in wav/avi */
  434. int parse_only; /* decoding only: if true, only parsing is done
  435. (function avcodec_parse_frame()). The frame
  436. data is returned. Only MPEG codecs support this now. */
  437. /**
  438. * 0-> h263 quant 1-> mpeg quant
  439. * encoding: set by user.
  440. * decoding: unused
  441. */
  442. int mpeg_quant;
  443. /**
  444. * pass1 encoding statistics output buffer
  445. * encoding: set by lavc
  446. * decoding: unused
  447. */
  448. char *stats_out; /* encoding statistics output buffer */
  449. /**
  450. * pass2 encoding statistics input buffer.
  451. * concatenated stuff from stats_out of pass1 should be placed here
  452. * encoding: allocated/set/freed by user
  453. * decoding: unused
  454. */
  455. char *stats_in;
  456. /**
  457. * ratecontrol qmin qmax limiting method
  458. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  459. * encoding: set by user.
  460. * decoding: unused
  461. */
  462. float rc_qsquish;
  463. float rc_qmod_amp;
  464. int rc_qmod_freq;
  465. /**
  466. * ratecontrol override, see RcOverride
  467. * encoding: allocated/set/freed by user.
  468. * decoding: unused
  469. */
  470. RcOverride *rc_override;
  471. int rc_override_count;
  472. /**
  473. * rate control equation
  474. * encoding: set by user
  475. * decoding: unused
  476. */
  477. char *rc_eq;
  478. /**
  479. * maximum bitrate
  480. * encoding: set by user.
  481. * decoding: unused
  482. */
  483. int rc_max_rate;
  484. /**
  485. * minimum bitrate
  486. * encoding: set by user.
  487. * decoding: unused
  488. */
  489. int rc_min_rate;
  490. /**
  491. * decoder bitstream buffer size
  492. * encoding: set by user.
  493. * decoding: unused
  494. */
  495. int rc_buffer_size;
  496. float rc_buffer_aggressivity;
  497. /**
  498. * qscale factor between p and i frames
  499. * encoding: set by user.
  500. * decoding: unused
  501. */
  502. float i_quant_factor;
  503. /**
  504. * qscale offset between p and i frames
  505. * encoding: set by user.
  506. * decoding: unused
  507. */
  508. float i_quant_offset;
  509. /**
  510. * initial complexity for pass1 ratecontrol
  511. * encoding: set by user.
  512. * decoding: unused
  513. */
  514. float rc_initial_cplx;
  515. /**
  516. * custom aspect ratio, used if aspect_info==FF_ASPECT_EXTENDED
  517. * encoding: set by user.
  518. * decoding: set by lavc.
  519. */
  520. int aspected_width;
  521. int aspected_height;
  522. /**
  523. * dct algorithm, see FF_DCT_* below
  524. * encoding: set by user
  525. * decoding: unused
  526. */
  527. int dct_algo;
  528. #define FF_DCT_AUTO 0
  529. #define FF_DCT_FASTINT 1
  530. #define FF_DCT_INT 2
  531. #define FF_DCT_MMX 3
  532. #define FF_DCT_MLIB 4
  533. /**
  534. * presentation timestamp in micro seconds (time when frame should be shown to user)
  535. * if 0 then the frame_rate will be used as reference
  536. * encoding: set by user
  537. * decoding; set by lavc
  538. */
  539. long long int pts;
  540. //FIXME this should be reordered after kabis API is finished ...
  541. //TODO kill kabi
  542. /*
  543. Note: Below are located reserved fields for further usage
  544. It requires for ABI !!!
  545. If you'll perform some changes then borrow new space from these fields
  546. (void * can be safety replaced with struct * ;)
  547. P L E A S E ! ! !
  548. Note: use avcodec_alloc_context instead of malloc to allocate this,
  549. otherwise the ABI compatibility will be broken between versions
  550. IMPORTANT: Never change order of already declared fields!!!
  551. */
  552. //TODO: remove mess below
  553. unsigned long long int
  554. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  555. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11;
  556. float
  557. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  558. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  559. void
  560. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  561. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  562. unsigned long int
  563. ul_res0,ul_res1,ul_res2,ul_res3,ul_res4,ul_res5,
  564. ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12;
  565. unsigned short int
  566. us_res0,us_res1,us_res2,us_res3,us_res4,us_res5,
  567. us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
  568. unsigned char
  569. uc_res0,uc_res1,uc_res2,uc_res3,uc_res4,uc_res5,
  570. uc_res6,uc_res7,uc_res8,uc_res9,uc_res10,uc_res11,uc_res12;
  571. unsigned int
  572. ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5,ui_res6,ui_res7,ui_res8,ui_res9,
  573. ui_res10,ui_res11,ui_res12,ui_res13,ui_res14,ui_res15,ui_res16;
  574. } AVCodecContext;
  575. typedef struct AVCodec {
  576. char *name;
  577. int type;
  578. int id;
  579. int priv_data_size;
  580. int (*init)(AVCodecContext *);
  581. int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
  582. int (*close)(AVCodecContext *);
  583. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  584. UINT8 *buf, int buf_size);
  585. int capabilities;
  586. struct AVCodec *next;
  587. /*
  588. Note: Below are located reserved fields for further usage
  589. It requires for ABI !!!
  590. If you'll perform some changes then borrow new space from these fields
  591. (void * can be safety replaced with struct * ;)
  592. P L E A S E ! ! !
  593. IMPORTANT: Never change order of already declared fields!!!
  594. */
  595. unsigned long long int
  596. ull_res0,ull_res1,ull_res2,ull_res3,ull_res4,ull_res5,
  597. ull_res6,ull_res7,ull_res8,ull_res9,ull_res10,ull_res11,ull_res12;
  598. float
  599. flt_res0,flt_res1,flt_res2,flt_res3,flt_res4,flt_res5,
  600. flt_res6,flt_res7,flt_res8,flt_res9,flt_res10,flt_res11,flt_res12;
  601. void
  602. *ptr_res0,*ptr_res1,*ptr_res2,*ptr_res3,*ptr_res4,*ptr_res5,
  603. *ptr_res6,*ptr_res7,*ptr_res8,*ptr_res9,*ptr_res10,*ptr_res11,*ptr_res12;
  604. } AVCodec;
  605. /* three components are given, that's all */
  606. typedef struct AVPicture {
  607. UINT8 *data[3];
  608. int linesize[3];
  609. } AVPicture;
  610. extern AVCodec ac3_encoder;
  611. extern AVCodec mp2_encoder;
  612. extern AVCodec mp3lame_encoder;
  613. extern AVCodec oggvorbis_encoder;
  614. extern AVCodec mpeg1video_encoder;
  615. extern AVCodec h263_encoder;
  616. extern AVCodec h263p_encoder;
  617. extern AVCodec rv10_encoder;
  618. extern AVCodec mjpeg_encoder;
  619. extern AVCodec mpeg4_encoder;
  620. extern AVCodec msmpeg4v1_encoder;
  621. extern AVCodec msmpeg4v2_encoder;
  622. extern AVCodec msmpeg4v3_encoder;
  623. extern AVCodec wmv1_encoder;
  624. extern AVCodec wmv2_encoder;
  625. extern AVCodec h263_decoder;
  626. extern AVCodec mpeg4_decoder;
  627. extern AVCodec msmpeg4v1_decoder;
  628. extern AVCodec msmpeg4v2_decoder;
  629. extern AVCodec msmpeg4v3_decoder;
  630. extern AVCodec wmv1_decoder;
  631. extern AVCodec wmv2_decoder;
  632. extern AVCodec mpeg_decoder;
  633. extern AVCodec h263i_decoder;
  634. extern AVCodec rv10_decoder;
  635. extern AVCodec svq1_decoder;
  636. extern AVCodec mjpeg_decoder;
  637. extern AVCodec mp2_decoder;
  638. extern AVCodec mp3_decoder;
  639. /* pcm codecs */
  640. #define PCM_CODEC(id, name) \
  641. extern AVCodec name ## _decoder; \
  642. extern AVCodec name ## _encoder;
  643. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  644. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  645. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  646. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  647. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  648. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  649. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  650. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  651. /* adpcm codecs */
  652. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  653. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  654. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  655. #undef PCM_CODEC
  656. /* dummy raw video codec */
  657. extern AVCodec rawvideo_codec;
  658. /* the following codecs use external GPL libs */
  659. extern AVCodec ac3_decoder;
  660. /* resample.c */
  661. struct ReSampleContext;
  662. typedef struct ReSampleContext ReSampleContext;
  663. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  664. int output_rate, int input_rate);
  665. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  666. void audio_resample_close(ReSampleContext *s);
  667. /* YUV420 format is assumed ! */
  668. struct ImgReSampleContext;
  669. typedef struct ImgReSampleContext ImgReSampleContext;
  670. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  671. int input_width, int input_height);
  672. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  673. int iwidth, int iheight,
  674. int topBand, int bottomBand,
  675. int leftBand, int rightBand);
  676. void img_resample(ImgReSampleContext *s,
  677. AVPicture *output, AVPicture *input);
  678. void img_resample_close(ImgReSampleContext *s);
  679. void avpicture_fill(AVPicture *picture, UINT8 *ptr,
  680. int pix_fmt, int width, int height);
  681. int avpicture_get_size(int pix_fmt, int width, int height);
  682. /* convert among pixel formats */
  683. int img_convert(AVPicture *dst, int dst_pix_fmt,
  684. AVPicture *src, int pix_fmt,
  685. int width, int height);
  686. /* deinterlace a picture */
  687. int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
  688. int pix_fmt, int width, int height);
  689. /* external high level API */
  690. extern AVCodec *first_avcodec;
  691. /* returns LIBAVCODEC_VERSION_INT constant */
  692. unsigned avcodec_version(void);
  693. /* returns LIBAVCODEC_BUILD constant */
  694. unsigned avcodec_build(void);
  695. void avcodec_init(void);
  696. void avcodec_set_bit_exact(void);
  697. void register_avcodec(AVCodec *format);
  698. AVCodec *avcodec_find_encoder(enum CodecID id);
  699. AVCodec *avcodec_find_encoder_by_name(const char *name);
  700. AVCodec *avcodec_find_decoder(enum CodecID id);
  701. AVCodec *avcodec_find_decoder_by_name(const char *name);
  702. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  703. AVCodecContext *avcodec_alloc_context();
  704. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  705. int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
  706. int *frame_size_ptr,
  707. UINT8 *buf, int buf_size);
  708. int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture,
  709. int *got_picture_ptr,
  710. UINT8 *buf, int buf_size);
  711. int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
  712. int *data_size_ptr,
  713. UINT8 *buf, int buf_size);
  714. int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  715. const short *samples);
  716. int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
  717. const AVPicture *pict);
  718. int avcodec_close(AVCodecContext *avctx);
  719. void avcodec_register_all(void);
  720. void avcodec_flush_buffers(AVCodecContext *avctx);
  721. #ifdef FF_POSTPROCESS
  722. extern int quant_store[MBR+1][MBC+1]; // [Review]
  723. #endif
  724. /**
  725. * Interface for 0.5.0 version
  726. *
  727. * do not even think about it's usage for this moment
  728. */
  729. typedef struct {
  730. // compressed size used from given memory buffer
  731. int size;
  732. /// I/P/B frame type
  733. int frame_type;
  734. } avc_enc_result_t;
  735. /**
  736. * Commands
  737. * order can't be changed - once it was defined
  738. */
  739. typedef enum {
  740. // general commands
  741. AVC_OPEN_BY_NAME = 0xACA000,
  742. AVC_OPEN_BY_CODEC_ID,
  743. AVC_OPEN_BY_FOURCC,
  744. AVC_CLOSE,
  745. AVC_FLUSH,
  746. // pin - struct { uint8_t* src, uint_t src_size }
  747. // pout - struct { AVPicture* img, consumed_bytes,
  748. AVC_DECODE,
  749. // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
  750. // pout - uint_t used_from_dest_size
  751. AVC_ENCODE,
  752. // query/get video commands
  753. AVC_GET_VERSION = 0xACB000,
  754. AVC_GET_WIDTH,
  755. AVC_GET_HEIGHT,
  756. AVC_GET_DELAY,
  757. AVC_GET_QUANT_TABLE,
  758. // ...
  759. // query/get audio commands
  760. AVC_GET_FRAME_SIZE = 0xABC000,
  761. // maybe define some simple structure which
  762. // might be passed to the user - but they can't
  763. // contain any codec specific parts and these
  764. // calls are usualy necessary only few times
  765. // set video commands
  766. AVC_SET_WIDTH = 0xACD000,
  767. AVC_SET_HEIGHT,
  768. // set video encoding commands
  769. AVC_SET_FRAME_RATE = 0xACD800,
  770. AVC_SET_QUALITY,
  771. AVC_SET_HURRY_UP,
  772. // set audio commands
  773. AVC_SET_SAMPLE_RATE = 0xACE000,
  774. AVC_SET_CHANNELS,
  775. } avc_cmd_t;
  776. /**
  777. * \param handle allocated private structure by libavcodec
  778. * for initialization pass NULL - will be returned pout
  779. * user is supposed to know nothing about its structure
  780. * \param cmd type of operation to be performed
  781. * \param pint input parameter
  782. * \param pout output parameter
  783. *
  784. * \returns command status - eventually for query command it might return
  785. * integer resulting value
  786. */
  787. int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
  788. /* memory */
  789. void *av_malloc(int size);
  790. void *av_mallocz(int size);
  791. void av_free(void *ptr);
  792. void __av_freep(void **ptr);
  793. #define av_freep(p) __av_freep((void **)(p))
  794. #endif /* AVCODEC_H */