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.

976 lines
28KB

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