avcodec.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675
  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_H
  19. #define AVCODEC_H
  20. /**
  21. * @file avcodec.h
  22. * external api header.
  23. */
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include "avutil.h"
  28. #include <sys/types.h> /* size_t */
  29. #define AV_STRINGIFY(s) AV_TOSTRING(s)
  30. #define AV_TOSTRING(s) #s
  31. #define LIBAVCODEC_VERSION_INT ((51<<16)+(14<<8)+0)
  32. #define LIBAVCODEC_VERSION 51.14.0
  33. #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
  34. #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
  35. #define AV_NOPTS_VALUE int64_t_C(0x8000000000000000)
  36. #define AV_TIME_BASE 1000000
  37. #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
  38. enum CodecID {
  39. CODEC_ID_NONE,
  40. CODEC_ID_MPEG1VIDEO,
  41. CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
  42. CODEC_ID_MPEG2VIDEO_XVMC,
  43. CODEC_ID_H261,
  44. CODEC_ID_H263,
  45. CODEC_ID_RV10,
  46. CODEC_ID_RV20,
  47. CODEC_ID_MJPEG,
  48. CODEC_ID_MJPEGB,
  49. CODEC_ID_LJPEG,
  50. CODEC_ID_SP5X,
  51. CODEC_ID_JPEGLS,
  52. CODEC_ID_MPEG4,
  53. CODEC_ID_RAWVIDEO,
  54. CODEC_ID_MSMPEG4V1,
  55. CODEC_ID_MSMPEG4V2,
  56. CODEC_ID_MSMPEG4V3,
  57. CODEC_ID_WMV1,
  58. CODEC_ID_WMV2,
  59. CODEC_ID_H263P,
  60. CODEC_ID_H263I,
  61. CODEC_ID_FLV1,
  62. CODEC_ID_SVQ1,
  63. CODEC_ID_SVQ3,
  64. CODEC_ID_DVVIDEO,
  65. CODEC_ID_HUFFYUV,
  66. CODEC_ID_CYUV,
  67. CODEC_ID_H264,
  68. CODEC_ID_INDEO3,
  69. CODEC_ID_VP3,
  70. CODEC_ID_THEORA,
  71. CODEC_ID_ASV1,
  72. CODEC_ID_ASV2,
  73. CODEC_ID_FFV1,
  74. CODEC_ID_4XM,
  75. CODEC_ID_VCR1,
  76. CODEC_ID_CLJR,
  77. CODEC_ID_MDEC,
  78. CODEC_ID_ROQ,
  79. CODEC_ID_INTERPLAY_VIDEO,
  80. CODEC_ID_XAN_WC3,
  81. CODEC_ID_XAN_WC4,
  82. CODEC_ID_RPZA,
  83. CODEC_ID_CINEPAK,
  84. CODEC_ID_WS_VQA,
  85. CODEC_ID_MSRLE,
  86. CODEC_ID_MSVIDEO1,
  87. CODEC_ID_IDCIN,
  88. CODEC_ID_8BPS,
  89. CODEC_ID_SMC,
  90. CODEC_ID_FLIC,
  91. CODEC_ID_TRUEMOTION1,
  92. CODEC_ID_VMDVIDEO,
  93. CODEC_ID_MSZH,
  94. CODEC_ID_ZLIB,
  95. CODEC_ID_QTRLE,
  96. CODEC_ID_SNOW,
  97. CODEC_ID_TSCC,
  98. CODEC_ID_ULTI,
  99. CODEC_ID_QDRAW,
  100. CODEC_ID_VIXL,
  101. CODEC_ID_QPEG,
  102. CODEC_ID_XVID,
  103. CODEC_ID_PNG,
  104. CODEC_ID_PPM,
  105. CODEC_ID_PBM,
  106. CODEC_ID_PGM,
  107. CODEC_ID_PGMYUV,
  108. CODEC_ID_PAM,
  109. CODEC_ID_FFVHUFF,
  110. CODEC_ID_RV30,
  111. CODEC_ID_RV40,
  112. CODEC_ID_VC1,
  113. CODEC_ID_WMV3,
  114. CODEC_ID_LOCO,
  115. CODEC_ID_WNV1,
  116. CODEC_ID_AASC,
  117. CODEC_ID_INDEO2,
  118. CODEC_ID_FRAPS,
  119. CODEC_ID_TRUEMOTION2,
  120. CODEC_ID_BMP,
  121. CODEC_ID_CSCD,
  122. CODEC_ID_MMVIDEO,
  123. CODEC_ID_ZMBV,
  124. CODEC_ID_AVS,
  125. CODEC_ID_SMACKVIDEO,
  126. CODEC_ID_NUV,
  127. CODEC_ID_KMVC,
  128. CODEC_ID_FLASHSV,
  129. CODEC_ID_CAVS,
  130. CODEC_ID_JPEG2000,
  131. CODEC_ID_VMNC,
  132. CODEC_ID_VP5,
  133. CODEC_ID_VP6,
  134. CODEC_ID_VP6F,
  135. /* various pcm "codecs" */
  136. CODEC_ID_PCM_S16LE= 0x10000,
  137. CODEC_ID_PCM_S16BE,
  138. CODEC_ID_PCM_U16LE,
  139. CODEC_ID_PCM_U16BE,
  140. CODEC_ID_PCM_S8,
  141. CODEC_ID_PCM_U8,
  142. CODEC_ID_PCM_MULAW,
  143. CODEC_ID_PCM_ALAW,
  144. CODEC_ID_PCM_S32LE,
  145. CODEC_ID_PCM_S32BE,
  146. CODEC_ID_PCM_U32LE,
  147. CODEC_ID_PCM_U32BE,
  148. CODEC_ID_PCM_S24LE,
  149. CODEC_ID_PCM_S24BE,
  150. CODEC_ID_PCM_U24LE,
  151. CODEC_ID_PCM_U24BE,
  152. CODEC_ID_PCM_S24DAUD,
  153. /* various adpcm codecs */
  154. CODEC_ID_ADPCM_IMA_QT= 0x11000,
  155. CODEC_ID_ADPCM_IMA_WAV,
  156. CODEC_ID_ADPCM_IMA_DK3,
  157. CODEC_ID_ADPCM_IMA_DK4,
  158. CODEC_ID_ADPCM_IMA_WS,
  159. CODEC_ID_ADPCM_IMA_SMJPEG,
  160. CODEC_ID_ADPCM_MS,
  161. CODEC_ID_ADPCM_4XM,
  162. CODEC_ID_ADPCM_XA,
  163. CODEC_ID_ADPCM_ADX,
  164. CODEC_ID_ADPCM_EA,
  165. CODEC_ID_ADPCM_G726,
  166. CODEC_ID_ADPCM_CT,
  167. CODEC_ID_ADPCM_SWF,
  168. CODEC_ID_ADPCM_YAMAHA,
  169. CODEC_ID_ADPCM_SBPRO_4,
  170. CODEC_ID_ADPCM_SBPRO_3,
  171. CODEC_ID_ADPCM_SBPRO_2,
  172. /* AMR */
  173. CODEC_ID_AMR_NB= 0x12000,
  174. CODEC_ID_AMR_WB,
  175. /* RealAudio codecs*/
  176. CODEC_ID_RA_144= 0x13000,
  177. CODEC_ID_RA_288,
  178. /* various DPCM codecs */
  179. CODEC_ID_ROQ_DPCM= 0x14000,
  180. CODEC_ID_INTERPLAY_DPCM,
  181. CODEC_ID_XAN_DPCM,
  182. CODEC_ID_SOL_DPCM,
  183. CODEC_ID_MP2= 0x15000,
  184. CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
  185. CODEC_ID_AAC,
  186. CODEC_ID_MPEG4AAC,
  187. CODEC_ID_AC3,
  188. CODEC_ID_DTS,
  189. CODEC_ID_VORBIS,
  190. CODEC_ID_DVAUDIO,
  191. CODEC_ID_WMAV1,
  192. CODEC_ID_WMAV2,
  193. CODEC_ID_MACE3,
  194. CODEC_ID_MACE6,
  195. CODEC_ID_VMDAUDIO,
  196. CODEC_ID_SONIC,
  197. CODEC_ID_SONIC_LS,
  198. CODEC_ID_FLAC,
  199. CODEC_ID_MP3ADU,
  200. CODEC_ID_MP3ON4,
  201. CODEC_ID_SHORTEN,
  202. CODEC_ID_ALAC,
  203. CODEC_ID_WESTWOOD_SND1,
  204. CODEC_ID_GSM,
  205. CODEC_ID_QDM2,
  206. CODEC_ID_COOK,
  207. CODEC_ID_TRUESPEECH,
  208. CODEC_ID_TTA,
  209. CODEC_ID_SMACKAUDIO,
  210. CODEC_ID_QCELP,
  211. /* subtitle codecs */
  212. CODEC_ID_DVD_SUBTITLE= 0x17000,
  213. CODEC_ID_DVB_SUBTITLE,
  214. CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
  215. stream (only used by libavformat) */
  216. };
  217. /* CODEC_ID_MP3LAME is absolete */
  218. #define CODEC_ID_MP3LAME CODEC_ID_MP3
  219. enum CodecType {
  220. CODEC_TYPE_UNKNOWN = -1,
  221. CODEC_TYPE_VIDEO,
  222. CODEC_TYPE_AUDIO,
  223. CODEC_TYPE_DATA,
  224. CODEC_TYPE_SUBTITLE,
  225. };
  226. /* currently unused, may be used if 24/32 bits samples ever supported */
  227. /* all in native endian */
  228. enum SampleFormat {
  229. SAMPLE_FMT_NONE = -1,
  230. SAMPLE_FMT_U8, ///< unsigned 8 bits
  231. SAMPLE_FMT_S16, ///< signed 16 bits
  232. SAMPLE_FMT_S24, ///< signed 24 bits
  233. SAMPLE_FMT_S32, ///< signed 32 bits
  234. SAMPLE_FMT_FLT, ///< float
  235. };
  236. /* in bytes */
  237. #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
  238. /**
  239. * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
  240. * this is mainly needed because some optimized bitstream readers read
  241. * 32 or 64 bit at once and could read over the end<br>
  242. * Note, if the first 23 bits of the additional bytes are not 0 then damaged
  243. * MPEG bitstreams could cause overread and segfault
  244. */
  245. #define FF_INPUT_BUFFER_PADDING_SIZE 8
  246. /**
  247. * minimum encoding buffer size.
  248. * used to avoid some checks during header writing
  249. */
  250. #define FF_MIN_BUFFER_SIZE 16384
  251. /* motion estimation type, EPZS by default */
  252. enum Motion_Est_ID {
  253. ME_ZERO = 1,
  254. ME_FULL,
  255. ME_LOG,
  256. ME_PHODS,
  257. ME_EPZS,
  258. ME_X1,
  259. ME_HEX,
  260. ME_UMH,
  261. ME_ITER,
  262. };
  263. enum AVDiscard{
  264. //we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
  265. AVDISCARD_NONE =-16, ///< discard nothing
  266. AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
  267. AVDISCARD_NONREF = 8, ///< discard all non reference
  268. AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
  269. AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
  270. AVDISCARD_ALL = 48, ///< discard all
  271. };
  272. typedef struct RcOverride{
  273. int start_frame;
  274. int end_frame;
  275. int qscale; // if this is 0 then quality_factor will be used instead
  276. float quality_factor;
  277. } RcOverride;
  278. #define FF_MAX_B_FRAMES 16
  279. /* encoding support
  280. these flags can be passed in AVCodecContext.flags before initing
  281. Note: not everything is supported yet.
  282. */
  283. #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
  284. #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
  285. #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
  286. #define CODEC_FLAG_GMC 0x0020 ///< use GMC
  287. #define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
  288. #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
  289. /* parent program gurantees that the input for b-frame containing streams is not written to
  290. for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
  291. #define CODEC_FLAG_INPUT_PRESERVED 0x0100
  292. #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
  293. #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
  294. #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
  295. #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
  296. #define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges
  297. #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
  298. #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
  299. of only at frame boundaries */
  300. #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
  301. #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
  302. #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
  303. #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
  304. #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
  305. #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
  306. #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
  307. /* Fx : Flag for h263+ extra options */
  308. #define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
  309. #define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
  310. #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
  311. #define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
  312. #define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
  313. #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
  314. #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
  315. #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
  316. #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
  317. #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
  318. #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
  319. #define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
  320. #define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
  321. #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size
  322. #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding
  323. #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata
  324. #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references
  325. #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames
  326. #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 multiple references per partition
  327. #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
  328. #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
  329. #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
  330. #define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization
  331. #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
  332. #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
  333. /* Unsupported options :
  334. * Syntax Arithmetic coding (SAC)
  335. * Reference Picture Selection
  336. * Independant Segment Decoding */
  337. /* /Fx */
  338. /* codec capabilities */
  339. #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
  340. /**
  341. * Codec uses get_buffer() for allocating buffers.
  342. * direct rendering method 1
  343. */
  344. #define CODEC_CAP_DR1 0x0002
  345. /* if 'parse_only' field is true, then avcodec_parse_frame() can be
  346. used */
  347. #define CODEC_CAP_PARSE_ONLY 0x0004
  348. #define CODEC_CAP_TRUNCATED 0x0008
  349. /* codec can export data for HW decoding (XvMC) */
  350. #define CODEC_CAP_HWACCEL 0x0010
  351. /**
  352. * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
  353. * if this is not set, the codec is guranteed to never be feeded with NULL data
  354. */
  355. #define CODEC_CAP_DELAY 0x0020
  356. /**
  357. * Codec can be fed a final frame with a smaller size.
  358. * This can be used to prevent truncation of the last audio samples.
  359. */
  360. #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
  361. //the following defines may change, don't expect compatibility if you use them
  362. #define MB_TYPE_INTRA4x4 0x0001
  363. #define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
  364. #define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
  365. #define MB_TYPE_16x16 0x0008
  366. #define MB_TYPE_16x8 0x0010
  367. #define MB_TYPE_8x16 0x0020
  368. #define MB_TYPE_8x8 0x0040
  369. #define MB_TYPE_INTERLACED 0x0080
  370. #define MB_TYPE_DIRECT2 0x0100 //FIXME
  371. #define MB_TYPE_ACPRED 0x0200
  372. #define MB_TYPE_GMC 0x0400
  373. #define MB_TYPE_SKIP 0x0800
  374. #define MB_TYPE_P0L0 0x1000
  375. #define MB_TYPE_P1L0 0x2000
  376. #define MB_TYPE_P0L1 0x4000
  377. #define MB_TYPE_P1L1 0x8000
  378. #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
  379. #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
  380. #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
  381. #define MB_TYPE_QUANT 0x00010000
  382. #define MB_TYPE_CBP 0x00020000
  383. //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
  384. /**
  385. * Pan Scan area.
  386. * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
  387. */
  388. typedef struct AVPanScan{
  389. /**
  390. * id.
  391. * - encoding: set by user.
  392. * - decoding: set by lavc
  393. */
  394. int id;
  395. /**
  396. * width and height in 1/16 pel
  397. * - encoding: set by user.
  398. * - decoding: set by lavc
  399. */
  400. int width;
  401. int height;
  402. /**
  403. * position of the top left corner in 1/16 pel for up to 3 fields/frames.
  404. * - encoding: set by user.
  405. * - decoding: set by lavc
  406. */
  407. int16_t position[3][2];
  408. }AVPanScan;
  409. #define FF_COMMON_FRAME \
  410. /**\
  411. * pointer to the picture planes.\
  412. * this might be different from the first allocated byte\
  413. * - encoding: \
  414. * - decoding: \
  415. */\
  416. uint8_t *data[4];\
  417. int linesize[4];\
  418. /**\
  419. * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
  420. * this isn't used by lavc unless the default get/release_buffer() is used\
  421. * - encoding: \
  422. * - decoding: \
  423. */\
  424. uint8_t *base[4];\
  425. /**\
  426. * 1 -> keyframe, 0-> not\
  427. * - encoding: set by lavc\
  428. * - decoding: set by lavc\
  429. */\
  430. int key_frame;\
  431. \
  432. /**\
  433. * picture type of the frame, see ?_TYPE below.\
  434. * - encoding: set by lavc for coded_picture (and set by user for input)\
  435. * - decoding: set by lavc\
  436. */\
  437. int pict_type;\
  438. \
  439. /**\
  440. * presentation timestamp in time_base units (time when frame should be shown to user)\
  441. * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\
  442. * - encoding: MUST be set by user\
  443. * - decoding: set by lavc\
  444. */\
  445. int64_t pts;\
  446. \
  447. /**\
  448. * picture number in bitstream order.\
  449. * - encoding: set by\
  450. * - decoding: set by lavc\
  451. */\
  452. int coded_picture_number;\
  453. /**\
  454. * picture number in display order.\
  455. * - encoding: set by\
  456. * - decoding: set by lavc\
  457. */\
  458. int display_picture_number;\
  459. \
  460. /**\
  461. * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
  462. * - encoding: set by lavc for coded_picture (and set by user for input)\
  463. * - decoding: set by lavc\
  464. */\
  465. int quality; \
  466. \
  467. /**\
  468. * buffer age (1->was last buffer and dint change, 2->..., ...).\
  469. * set to INT_MAX if the buffer has not been used yet \
  470. * - encoding: unused\
  471. * - decoding: MUST be set by get_buffer()\
  472. */\
  473. int age;\
  474. \
  475. /**\
  476. * is this picture used as reference\
  477. * - encoding: unused\
  478. * - decoding: set by lavc (before get_buffer() call))\
  479. */\
  480. int reference;\
  481. \
  482. /**\
  483. * QP table\
  484. * - encoding: unused\
  485. * - decoding: set by lavc\
  486. */\
  487. int8_t *qscale_table;\
  488. /**\
  489. * QP store stride\
  490. * - encoding: unused\
  491. * - decoding: set by lavc\
  492. */\
  493. int qstride;\
  494. \
  495. /**\
  496. * mbskip_table[mb]>=1 if MB didnt change\
  497. * stride= mb_width = (width+15)>>4\
  498. * - encoding: unused\
  499. * - decoding: set by lavc\
  500. */\
  501. uint8_t *mbskip_table;\
  502. \
  503. /**\
  504. * Motion vector table.\
  505. * @code\
  506. * example:\
  507. * int mv_sample_log2= 4 - motion_subsample_log2;\
  508. * int mb_width= (width+15)>>4;\
  509. * int mv_stride= (mb_width << mv_sample_log2) + 1;\
  510. * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
  511. * @endcode\
  512. * - encoding: set by user\
  513. * - decoding: set by lavc\
  514. */\
  515. int16_t (*motion_val[2])[2];\
  516. \
  517. /**\
  518. * Macroblock type table\
  519. * mb_type_base + mb_width + 2\
  520. * - encoding: set by user\
  521. * - decoding: set by lavc\
  522. */\
  523. uint32_t *mb_type;\
  524. \
  525. /**\
  526. * log2 of the size of the block which a single vector in motion_val represents: \
  527. * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
  528. * - encoding: unused\
  529. * - decoding: set by lavc\
  530. */\
  531. uint8_t motion_subsample_log2;\
  532. \
  533. /**\
  534. * for some private data of the user\
  535. * - encoding: unused\
  536. * - decoding: set by user\
  537. */\
  538. void *opaque;\
  539. \
  540. /**\
  541. * error\
  542. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
  543. * - decoding: unused\
  544. */\
  545. uint64_t error[4];\
  546. \
  547. /**\
  548. * type of the buffer (to keep track of who has to dealloc data[*])\
  549. * - encoding: set by the one who allocs it\
  550. * - decoding: set by the one who allocs it\
  551. * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
  552. */\
  553. int type;\
  554. \
  555. /**\
  556. * when decoding, this signal how much the picture must be delayed.\
  557. * extra_delay = repeat_pict / (2*fps)\
  558. * - encoding: unused\
  559. * - decoding: set by lavc\
  560. */\
  561. int repeat_pict;\
  562. \
  563. /**\
  564. * \
  565. */\
  566. int qscale_type;\
  567. \
  568. /**\
  569. * The content of the picture is interlaced.\
  570. * - encoding: set by user\
  571. * - decoding: set by lavc (default 0)\
  572. */\
  573. int interlaced_frame;\
  574. \
  575. /**\
  576. * if the content is interlaced, is top field displayed first.\
  577. * - encoding: set by user\
  578. * - decoding: set by lavc\
  579. */\
  580. int top_field_first;\
  581. \
  582. /**\
  583. * Pan scan.\
  584. * - encoding: set by user\
  585. * - decoding: set by lavc\
  586. */\
  587. AVPanScan *pan_scan;\
  588. \
  589. /**\
  590. * tell user application that palette has changed from previous frame.\
  591. * - encoding: ??? (no palette-enabled encoder yet)\
  592. * - decoding: set by lavc (default 0)\
  593. */\
  594. int palette_has_changed;\
  595. \
  596. /**\
  597. * Codec suggestion on buffer type if != 0\
  598. * - encoding: unused\
  599. * - decoding: set by lavc (before get_buffer() call))\
  600. */\
  601. int buffer_hints;\
  602. \
  603. /**\
  604. * DCT coeffitients\
  605. * - encoding: unused\
  606. * - decoding: set by lavc\
  607. */\
  608. short *dct_coeff;\
  609. \
  610. /**\
  611. * Motion referece frame index\
  612. * - encoding: set by user\
  613. * - decoding: set by lavc\
  614. */\
  615. int8_t *ref_index[2];
  616. #define FF_QSCALE_TYPE_MPEG1 0
  617. #define FF_QSCALE_TYPE_MPEG2 1
  618. #define FF_QSCALE_TYPE_H264 2
  619. #define FF_BUFFER_TYPE_INTERNAL 1
  620. #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
  621. #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
  622. #define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything
  623. #define FF_I_TYPE 1 // Intra
  624. #define FF_P_TYPE 2 // Predicted
  625. #define FF_B_TYPE 3 // Bi-dir predicted
  626. #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
  627. #define FF_SI_TYPE 5
  628. #define FF_SP_TYPE 6
  629. #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
  630. #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
  631. #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
  632. #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
  633. /**
  634. * Audio Video Frame.
  635. */
  636. typedef struct AVFrame {
  637. FF_COMMON_FRAME
  638. } AVFrame;
  639. #define DEFAULT_FRAME_RATE_BASE 1001000
  640. /**
  641. * main external api structure.
  642. */
  643. typedef struct AVCodecContext {
  644. /**
  645. * Info on struct for av_log
  646. * - set by avcodec_alloc_context
  647. */
  648. AVClass *av_class;
  649. /**
  650. * the average bitrate.
  651. * - encoding: set by user. unused for constant quantizer encoding
  652. * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
  653. */
  654. int bit_rate;
  655. /**
  656. * number of bits the bitstream is allowed to diverge from the reference.
  657. * the reference can be CBR (for CBR pass1) or VBR (for pass2)
  658. * - encoding: set by user. unused for constant quantizer encoding
  659. * - decoding: unused
  660. */
  661. int bit_rate_tolerance;
  662. /**
  663. * CODEC_FLAG_*.
  664. * - encoding: set by user.
  665. * - decoding: set by user.
  666. */
  667. int flags;
  668. /**
  669. * some codecs needs additionnal format info. It is stored here
  670. * - encoding: set by user.
  671. * - decoding: set by lavc. (FIXME is this ok?)
  672. */
  673. int sub_id;
  674. /**
  675. * motion estimation algorithm used for video coding.
  676. * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
  677. * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
  678. * - encoding: MUST be set by user.
  679. * - decoding: unused
  680. */
  681. int me_method;
  682. /**
  683. * some codecs need / can use extra-data like huffman tables.
  684. * mjpeg: huffman tables
  685. * rv10: additional flags
  686. * mpeg4: global headers (they can be in the bitstream or here)
  687. * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
  688. * then extradata_size to avoid prolems if its read with the bitstream reader
  689. * the bytewise contents of extradata must not depend on the architecture or cpu endianness
  690. * - encoding: set/allocated/freed by lavc.
  691. * - decoding: set/allocated/freed by user.
  692. */
  693. void *extradata;
  694. int extradata_size;
  695. /**
  696. * this is the fundamental unit of time (in seconds) in terms
  697. * of which frame timestamps are represented. for fixed-fps content,
  698. * timebase should be 1/framerate and timestamp increments should be
  699. * identically 1.
  700. * - encoding: MUST be set by user
  701. * - decoding: set by lavc.
  702. */
  703. AVRational time_base;
  704. /* video only */
  705. /**
  706. * picture width / height.
  707. * - encoding: MUST be set by user.
  708. * - decoding: set by lavc.
  709. * Note, for compatibility its possible to set this instead of
  710. * coded_width/height before decoding
  711. */
  712. int width, height;
  713. #define FF_ASPECT_EXTENDED 15
  714. /**
  715. * the number of pictures in a group of pitures, or 0 for intra_only.
  716. * - encoding: set by user.
  717. * - decoding: unused
  718. */
  719. int gop_size;
  720. /**
  721. * pixel format, see PIX_FMT_xxx.
  722. * - encoding: set by user.
  723. * - decoding: set by lavc.
  724. */
  725. enum PixelFormat pix_fmt;
  726. /**
  727. * Frame rate emulation. If not zero lower layer (i.e. format handler)
  728. * has to read frames at native frame rate.
  729. * - encoding: set by user.
  730. * - decoding: unused.
  731. */
  732. int rate_emu;
  733. /**
  734. * if non NULL, 'draw_horiz_band' is called by the libavcodec
  735. * decoder to draw an horizontal band. It improve cache usage. Not
  736. * all codecs can do that. You must check the codec capabilities
  737. * before
  738. * - encoding: unused
  739. * - decoding: set by user.
  740. * @param height the height of the slice
  741. * @param y the y position of the slice
  742. * @param type 1->top field, 2->bottom field, 3->frame
  743. * @param offset offset into the AVFrame.data from which the slice should be read
  744. */
  745. void (*draw_horiz_band)(struct AVCodecContext *s,
  746. const AVFrame *src, int offset[4],
  747. int y, int type, int height);
  748. /* audio only */
  749. int sample_rate; ///< samples per sec
  750. int channels;
  751. /**
  752. * audio sample format.
  753. * - encoding: set by user.
  754. * - decoding: set by lavc.
  755. */
  756. enum SampleFormat sample_fmt; ///< sample format, currenly unused
  757. /* the following data should not be initialized */
  758. /**
  759. * samples per packet. initialized when calling 'init'
  760. */
  761. int frame_size;
  762. int frame_number; ///< audio or video frame number
  763. int real_pict_num; ///< returns the real picture number of previous encoded frame
  764. /**
  765. * number of frames the decoded output will be delayed relative to
  766. * the encoded input.
  767. * - encoding: set by lavc.
  768. * - decoding: unused
  769. */
  770. int delay;
  771. /* - encoding parameters */
  772. float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
  773. float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
  774. /**
  775. * minimum quantizer.
  776. * - encoding: set by user.
  777. * - decoding: unused
  778. */
  779. int qmin;
  780. /**
  781. * maximum quantizer.
  782. * - encoding: set by user.
  783. * - decoding: unused
  784. */
  785. int qmax;
  786. /**
  787. * maximum quantizer difference etween frames.
  788. * - encoding: set by user.
  789. * - decoding: unused
  790. */
  791. int max_qdiff;
  792. /**
  793. * maximum number of b frames between non b frames.
  794. * note: the output will be delayed by max_b_frames+1 relative to the input
  795. * - encoding: set by user.
  796. * - decoding: unused
  797. */
  798. int max_b_frames;
  799. /**
  800. * qscale factor between ip and b frames.
  801. * - encoding: set by user.
  802. * - decoding: unused
  803. */
  804. float b_quant_factor;
  805. /** obsolete FIXME remove */
  806. int rc_strategy;
  807. #define FF_RC_STRATEGY_XVID 1
  808. int b_frame_strategy;
  809. /**
  810. * hurry up amount.
  811. * deprecated in favor of skip_idct and skip_frame
  812. * - encoding: unused
  813. * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
  814. */
  815. int hurry_up;
  816. struct AVCodec *codec;
  817. void *priv_data;
  818. /* unused, FIXME remove*/
  819. int rtp_mode;
  820. int rtp_payload_size; /* The size of the RTP payload: the coder will */
  821. /* do it's best to deliver a chunk with size */
  822. /* below rtp_payload_size, the chunk will start */
  823. /* with a start code on some codecs like H.263 */
  824. /* This doesn't take account of any particular */
  825. /* headers inside the transmited RTP payload */
  826. /* The RTP callback: This function is called */
  827. /* every time the encoder has a packet to send */
  828. /* Depends on the encoder if the data starts */
  829. /* with a Start Code (it should) H.263 does. */
  830. /* mb_nb contains the number of macroblocks */
  831. /* encoded in the RTP payload */
  832. void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
  833. /* statistics, used for 2-pass encoding */
  834. int mv_bits;
  835. int header_bits;
  836. int i_tex_bits;
  837. int p_tex_bits;
  838. int i_count;
  839. int p_count;
  840. int skip_count;
  841. int misc_bits;
  842. /**
  843. * number of bits used for the previously encoded frame.
  844. * - encoding: set by lavc
  845. * - decoding: unused
  846. */
  847. int frame_bits;
  848. /**
  849. * private data of the user, can be used to carry app specific stuff.
  850. * - encoding: set by user
  851. * - decoding: set by user
  852. */
  853. void *opaque;
  854. char codec_name[32];
  855. enum CodecType codec_type; /* see CODEC_TYPE_xxx */
  856. enum CodecID codec_id; /* see CODEC_ID_xxx */
  857. /**
  858. * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  859. * this is used to workaround some encoder bugs
  860. * - encoding: set by user, if not then the default based on codec_id will be used
  861. * - decoding: set by user, will be converted to upper case by lavc during init
  862. */
  863. unsigned int codec_tag;
  864. /**
  865. * workaround bugs in encoders which sometimes cannot be detected automatically.
  866. * - encoding: set by user
  867. * - decoding: set by user
  868. */
  869. int workaround_bugs;
  870. #define FF_BUG_AUTODETECT 1 ///< autodetection
  871. #define FF_BUG_OLD_MSMPEG4 2
  872. #define FF_BUG_XVID_ILACE 4
  873. #define FF_BUG_UMP4 8
  874. #define FF_BUG_NO_PADDING 16
  875. #define FF_BUG_AMV 32
  876. #define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
  877. #define FF_BUG_QPEL_CHROMA 64
  878. #define FF_BUG_STD_QPEL 128
  879. #define FF_BUG_QPEL_CHROMA2 256
  880. #define FF_BUG_DIRECT_BLOCKSIZE 512
  881. #define FF_BUG_EDGE 1024
  882. #define FF_BUG_HPEL_CHROMA 2048
  883. #define FF_BUG_DC_CLIP 4096
  884. #define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders
  885. //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
  886. /**
  887. * luma single coeff elimination threshold.
  888. * - encoding: set by user
  889. * - decoding: unused
  890. */
  891. int luma_elim_threshold;
  892. /**
  893. * chroma single coeff elimination threshold.
  894. * - encoding: set by user
  895. * - decoding: unused
  896. */
  897. int chroma_elim_threshold;
  898. /**
  899. * strictly follow the std (MPEG4, ...).
  900. * - encoding: set by user
  901. * - decoding: unused
  902. */
  903. int strict_std_compliance;
  904. #define FF_COMPLIANCE_VERY_STRICT 2 ///< strictly conform to a older more strict version of the spec or reference software
  905. #define FF_COMPLIANCE_STRICT 1 ///< strictly conform to all the things in the spec no matter what consequences
  906. #define FF_COMPLIANCE_NORMAL 0
  907. #define FF_COMPLIANCE_INOFFICIAL -1 ///< allow inofficial extensions
  908. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things
  909. /**
  910. * qscale offset between ip and b frames.
  911. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  912. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  913. * - encoding: set by user.
  914. * - decoding: unused
  915. */
  916. float b_quant_offset;
  917. /**
  918. * error resilience higher values will detect more errors but may missdetect
  919. * some more or less valid parts as errors.
  920. * - encoding: unused
  921. * - decoding: set by user
  922. */
  923. int error_resilience;
  924. #define FF_ER_CAREFUL 1
  925. #define FF_ER_COMPLIANT 2
  926. #define FF_ER_AGGRESSIVE 3
  927. #define FF_ER_VERY_AGGRESSIVE 4
  928. /**
  929. * called at the beginning of each frame to get a buffer for it.
  930. * if pic.reference is set then the frame will be read later by lavc
  931. * avcodec_align_dimensions() should be used to find the required width and
  932. * height, as they normally need to be rounded up to the next multiple of 16
  933. * - encoding: unused
  934. * - decoding: set by lavc, user can override
  935. */
  936. int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
  937. /**
  938. * called to release buffers which where allocated with get_buffer.
  939. * a released buffer can be reused in get_buffer()
  940. * pic.data[*] must be set to NULL
  941. * - encoding: unused
  942. * - decoding: set by lavc, user can override
  943. */
  944. void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
  945. /**
  946. * if 1 the stream has a 1 frame delay during decoding.
  947. * - encoding: set by lavc
  948. * - decoding: set by lavc
  949. */
  950. int has_b_frames;
  951. /**
  952. * number of bytes per packet if constant and known or 0
  953. * used by some WAV based audio codecs
  954. */
  955. int block_align;
  956. int parse_only; /* - decoding only: if true, only parsing is done
  957. (function avcodec_parse_frame()). The frame
  958. data is returned. Only MPEG codecs support this now. */
  959. /**
  960. * 0-> h263 quant 1-> mpeg quant.
  961. * - encoding: set by user.
  962. * - decoding: unused
  963. */
  964. int mpeg_quant;
  965. /**
  966. * pass1 encoding statistics output buffer.
  967. * - encoding: set by lavc
  968. * - decoding: unused
  969. */
  970. char *stats_out;
  971. /**
  972. * pass2 encoding statistics input buffer.
  973. * concatenated stuff from stats_out of pass1 should be placed here
  974. * - encoding: allocated/set/freed by user
  975. * - decoding: unused
  976. */
  977. char *stats_in;
  978. /**
  979. * ratecontrol qmin qmax limiting method.
  980. * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
  981. * - encoding: set by user.
  982. * - decoding: unused
  983. */
  984. float rc_qsquish;
  985. float rc_qmod_amp;
  986. int rc_qmod_freq;
  987. /**
  988. * ratecontrol override, see RcOverride.
  989. * - encoding: allocated/set/freed by user.
  990. * - decoding: unused
  991. */
  992. RcOverride *rc_override;
  993. int rc_override_count;
  994. /**
  995. * rate control equation.
  996. * - encoding: set by user
  997. * - decoding: unused
  998. */
  999. char *rc_eq;
  1000. /**
  1001. * maximum bitrate.
  1002. * - encoding: set by user.
  1003. * - decoding: unused
  1004. */
  1005. int rc_max_rate;
  1006. /**
  1007. * minimum bitrate.
  1008. * - encoding: set by user.
  1009. * - decoding: unused
  1010. */
  1011. int rc_min_rate;
  1012. /**
  1013. * decoder bitstream buffer size.
  1014. * - encoding: set by user.
  1015. * - decoding: unused
  1016. */
  1017. int rc_buffer_size;
  1018. float rc_buffer_aggressivity;
  1019. /**
  1020. * qscale factor between p and i frames.
  1021. * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
  1022. * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
  1023. * - encoding: set by user.
  1024. * - decoding: unused
  1025. */
  1026. float i_quant_factor;
  1027. /**
  1028. * qscale offset between p and i frames.
  1029. * - encoding: set by user.
  1030. * - decoding: unused
  1031. */
  1032. float i_quant_offset;
  1033. /**
  1034. * initial complexity for pass1 ratecontrol.
  1035. * - encoding: set by user.
  1036. * - decoding: unused
  1037. */
  1038. float rc_initial_cplx;
  1039. /**
  1040. * dct algorithm, see FF_DCT_* below.
  1041. * - encoding: set by user
  1042. * - decoding: unused
  1043. */
  1044. int dct_algo;
  1045. #define FF_DCT_AUTO 0
  1046. #define FF_DCT_FASTINT 1
  1047. #define FF_DCT_INT 2
  1048. #define FF_DCT_MMX 3
  1049. #define FF_DCT_MLIB 4
  1050. #define FF_DCT_ALTIVEC 5
  1051. #define FF_DCT_FAAN 6
  1052. /**
  1053. * luminance masking (0-> disabled).
  1054. * - encoding: set by user
  1055. * - decoding: unused
  1056. */
  1057. float lumi_masking;
  1058. /**
  1059. * temporary complexity masking (0-> disabled).
  1060. * - encoding: set by user
  1061. * - decoding: unused
  1062. */
  1063. float temporal_cplx_masking;
  1064. /**
  1065. * spatial complexity masking (0-> disabled).
  1066. * - encoding: set by user
  1067. * - decoding: unused
  1068. */
  1069. float spatial_cplx_masking;
  1070. /**
  1071. * p block masking (0-> disabled).
  1072. * - encoding: set by user
  1073. * - decoding: unused
  1074. */
  1075. float p_masking;
  1076. /**
  1077. * darkness masking (0-> disabled).
  1078. * - encoding: set by user
  1079. * - decoding: unused
  1080. */
  1081. float dark_masking;
  1082. /* for binary compatibility */
  1083. int unused;
  1084. /**
  1085. * idct algorithm, see FF_IDCT_* below.
  1086. * - encoding: set by user
  1087. * - decoding: set by user
  1088. */
  1089. int idct_algo;
  1090. #define FF_IDCT_AUTO 0
  1091. #define FF_IDCT_INT 1
  1092. #define FF_IDCT_SIMPLE 2
  1093. #define FF_IDCT_SIMPLEMMX 3
  1094. #define FF_IDCT_LIBMPEG2MMX 4
  1095. #define FF_IDCT_PS2 5
  1096. #define FF_IDCT_MLIB 6
  1097. #define FF_IDCT_ARM 7
  1098. #define FF_IDCT_ALTIVEC 8
  1099. #define FF_IDCT_SH4 9
  1100. #define FF_IDCT_SIMPLEARM 10
  1101. #define FF_IDCT_H264 11
  1102. #define FF_IDCT_VP3 12
  1103. #define FF_IDCT_IPP 13
  1104. #define FF_IDCT_XVIDMMX 14
  1105. #define FF_IDCT_CAVS 15
  1106. /**
  1107. * slice count.
  1108. * - encoding: set by lavc
  1109. * - decoding: set by user (or 0)
  1110. */
  1111. int slice_count;
  1112. /**
  1113. * slice offsets in the frame in bytes.
  1114. * - encoding: set/allocated by lavc
  1115. * - decoding: set/allocated by user (or NULL)
  1116. */
  1117. int *slice_offset;
  1118. /**
  1119. * error concealment flags.
  1120. * - encoding: unused
  1121. * - decoding: set by user
  1122. */
  1123. int error_concealment;
  1124. #define FF_EC_GUESS_MVS 1
  1125. #define FF_EC_DEBLOCK 2
  1126. /**
  1127. * dsp_mask could be add used to disable unwanted CPU features
  1128. * CPU features (i.e. MMX, SSE. ...)
  1129. *
  1130. * with FORCE flag you may instead enable given CPU features
  1131. * (Dangerous: usable in case of misdetection, improper usage however will
  1132. * result into program crash)
  1133. */
  1134. unsigned dsp_mask;
  1135. #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
  1136. /* lower 16 bits - CPU features */
  1137. #ifdef HAVE_MMX
  1138. #define FF_MM_MMX 0x0001 /* standard MMX */
  1139. #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
  1140. #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
  1141. #define FF_MM_SSE 0x0008 /* SSE functions */
  1142. #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
  1143. #define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
  1144. #endif /* HAVE_MMX */
  1145. #ifdef HAVE_IWMMXT
  1146. #define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */
  1147. #endif /* HAVE_IWMMXT */
  1148. /**
  1149. * bits per sample/pixel from the demuxer (needed for huffyuv).
  1150. * - encoding: set by lavc
  1151. * - decoding: set by user
  1152. */
  1153. int bits_per_sample;
  1154. /**
  1155. * prediction method (needed for huffyuv).
  1156. * - encoding: set by user
  1157. * - decoding: unused
  1158. */
  1159. int prediction_method;
  1160. #define FF_PRED_LEFT 0
  1161. #define FF_PRED_PLANE 1
  1162. #define FF_PRED_MEDIAN 2
  1163. /**
  1164. * sample aspect ratio (0 if unknown).
  1165. * numerator and denominator must be relative prime and smaller then 256 for some video standards
  1166. * - encoding: set by user.
  1167. * - decoding: set by lavc.
  1168. */
  1169. AVRational sample_aspect_ratio;
  1170. /**
  1171. * the picture in the bitstream.
  1172. * - encoding: set by lavc
  1173. * - decoding: set by lavc
  1174. */
  1175. AVFrame *coded_frame;
  1176. /**
  1177. * debug.
  1178. * - encoding: set by user.
  1179. * - decoding: set by user.
  1180. */
  1181. int debug;
  1182. #define FF_DEBUG_PICT_INFO 1
  1183. #define FF_DEBUG_RC 2
  1184. #define FF_DEBUG_BITSTREAM 4
  1185. #define FF_DEBUG_MB_TYPE 8
  1186. #define FF_DEBUG_QP 16
  1187. #define FF_DEBUG_MV 32
  1188. #define FF_DEBUG_DCT_COEFF 0x00000040
  1189. #define FF_DEBUG_SKIP 0x00000080
  1190. #define FF_DEBUG_STARTCODE 0x00000100
  1191. #define FF_DEBUG_PTS 0x00000200
  1192. #define FF_DEBUG_ER 0x00000400
  1193. #define FF_DEBUG_MMCO 0x00000800
  1194. #define FF_DEBUG_BUGS 0x00001000
  1195. #define FF_DEBUG_VIS_QP 0x00002000
  1196. #define FF_DEBUG_VIS_MB_TYPE 0x00004000
  1197. /**
  1198. * debug.
  1199. * - encoding: set by user.
  1200. * - decoding: set by user.
  1201. */
  1202. int debug_mv;
  1203. #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
  1204. #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
  1205. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
  1206. /**
  1207. * error.
  1208. * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
  1209. * - decoding: unused
  1210. */
  1211. uint64_t error[4];
  1212. /**
  1213. * minimum MB quantizer.
  1214. * - encoding: unused
  1215. * - decoding: unused
  1216. */
  1217. int mb_qmin;
  1218. /**
  1219. * maximum MB quantizer.
  1220. * - encoding: unused
  1221. * - decoding: unused
  1222. */
  1223. int mb_qmax;
  1224. /**
  1225. * motion estimation compare function.
  1226. * - encoding: set by user.
  1227. * - decoding: unused
  1228. */
  1229. int me_cmp;
  1230. /**
  1231. * subpixel motion estimation compare function.
  1232. * - encoding: set by user.
  1233. * - decoding: unused
  1234. */
  1235. int me_sub_cmp;
  1236. /**
  1237. * macroblock compare function (not supported yet).
  1238. * - encoding: set by user.
  1239. * - decoding: unused
  1240. */
  1241. int mb_cmp;
  1242. /**
  1243. * interlaced dct compare function
  1244. * - encoding: set by user.
  1245. * - decoding: unused
  1246. */
  1247. int ildct_cmp;
  1248. #define FF_CMP_SAD 0
  1249. #define FF_CMP_SSE 1
  1250. #define FF_CMP_SATD 2
  1251. #define FF_CMP_DCT 3
  1252. #define FF_CMP_PSNR 4
  1253. #define FF_CMP_BIT 5
  1254. #define FF_CMP_RD 6
  1255. #define FF_CMP_ZERO 7
  1256. #define FF_CMP_VSAD 8
  1257. #define FF_CMP_VSSE 9
  1258. #define FF_CMP_NSSE 10
  1259. #define FF_CMP_W53 11
  1260. #define FF_CMP_W97 12
  1261. #define FF_CMP_DCTMAX 13
  1262. #define FF_CMP_DCT264 14
  1263. #define FF_CMP_CHROMA 256
  1264. /**
  1265. * ME diamond size & shape.
  1266. * - encoding: set by user.
  1267. * - decoding: unused
  1268. */
  1269. int dia_size;
  1270. /**
  1271. * amount of previous MV predictors (2a+1 x 2a+1 square).
  1272. * - encoding: set by user.
  1273. * - decoding: unused
  1274. */
  1275. int last_predictor_count;
  1276. /**
  1277. * pre pass for motion estimation.
  1278. * - encoding: set by user.
  1279. * - decoding: unused
  1280. */
  1281. int pre_me;
  1282. /**
  1283. * motion estimation pre pass compare function.
  1284. * - encoding: set by user.
  1285. * - decoding: unused
  1286. */
  1287. int me_pre_cmp;
  1288. /**
  1289. * ME pre pass diamond size & shape.
  1290. * - encoding: set by user.
  1291. * - decoding: unused
  1292. */
  1293. int pre_dia_size;
  1294. /**
  1295. * subpel ME quality.
  1296. * - encoding: set by user.
  1297. * - decoding: unused
  1298. */
  1299. int me_subpel_quality;
  1300. /**
  1301. * callback to negotiate the pixelFormat.
  1302. * @param fmt is the list of formats which are supported by the codec,
  1303. * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
  1304. * the first is allways the native one
  1305. * @return the choosen format
  1306. * - encoding: unused
  1307. * - decoding: set by user, if not set then the native format will always be choosen
  1308. */
  1309. enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
  1310. /**
  1311. * DTG active format information (additionnal aspect ratio
  1312. * information only used in DVB MPEG2 transport streams). 0 if
  1313. * not set.
  1314. *
  1315. * - encoding: unused.
  1316. * - decoding: set by decoder
  1317. */
  1318. int dtg_active_format;
  1319. #define FF_DTG_AFD_SAME 8
  1320. #define FF_DTG_AFD_4_3 9
  1321. #define FF_DTG_AFD_16_9 10
  1322. #define FF_DTG_AFD_14_9 11
  1323. #define FF_DTG_AFD_4_3_SP_14_9 13
  1324. #define FF_DTG_AFD_16_9_SP_14_9 14
  1325. #define FF_DTG_AFD_SP_4_3 15
  1326. /**
  1327. * Maximum motion estimation search range in subpel units.
  1328. * if 0 then no limit
  1329. *
  1330. * - encoding: set by user.
  1331. * - decoding: unused.
  1332. */
  1333. int me_range;
  1334. /**
  1335. * intra quantizer bias.
  1336. * - encoding: set by user.
  1337. * - decoding: unused
  1338. */
  1339. int intra_quant_bias;
  1340. #define FF_DEFAULT_QUANT_BIAS 999999
  1341. /**
  1342. * inter quantizer bias.
  1343. * - encoding: set by user.
  1344. * - decoding: unused
  1345. */
  1346. int inter_quant_bias;
  1347. /**
  1348. * color table ID.
  1349. * - encoding: unused.
  1350. * - decoding: which clrtable should be used for 8bit RGB images
  1351. * table have to be stored somewhere FIXME
  1352. */
  1353. int color_table_id;
  1354. /**
  1355. * internal_buffer count.
  1356. * Don't touch, used by lavc default_get_buffer()
  1357. */
  1358. int internal_buffer_count;
  1359. /**
  1360. * internal_buffers.
  1361. * Don't touch, used by lavc default_get_buffer()
  1362. */
  1363. void *internal_buffer;
  1364. #define FF_LAMBDA_SHIFT 7
  1365. #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
  1366. #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
  1367. #define FF_LAMBDA_MAX (256*128-1)
  1368. #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
  1369. /**
  1370. * global quality for codecs which cannot change it per frame.
  1371. * this should be proportional to MPEG1/2/4 qscale.
  1372. * - encoding: set by user.
  1373. * - decoding: unused
  1374. */
  1375. int global_quality;
  1376. #define FF_CODER_TYPE_VLC 0
  1377. #define FF_CODER_TYPE_AC 1
  1378. /**
  1379. * coder type
  1380. * - encoding: set by user.
  1381. * - decoding: unused
  1382. */
  1383. int coder_type;
  1384. /**
  1385. * context model
  1386. * - encoding: set by user.
  1387. * - decoding: unused
  1388. */
  1389. int context_model;
  1390. #if 0
  1391. /**
  1392. *
  1393. * - encoding: unused
  1394. * - decoding: set by user.
  1395. */
  1396. uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
  1397. #endif
  1398. /**
  1399. * slice flags
  1400. * - encoding: unused
  1401. * - decoding: set by user.
  1402. */
  1403. int slice_flags;
  1404. #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
  1405. #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
  1406. #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
  1407. /**
  1408. * XVideo Motion Acceleration
  1409. * - encoding: forbidden
  1410. * - decoding: set by decoder
  1411. */
  1412. int xvmc_acceleration;
  1413. /**
  1414. * macroblock decision mode
  1415. * - encoding: set by user.
  1416. * - decoding: unused
  1417. */
  1418. int mb_decision;
  1419. #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
  1420. #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
  1421. #define FF_MB_DECISION_RD 2 ///< rate distoration
  1422. /**
  1423. * custom intra quantization matrix
  1424. * - encoding: set by user, can be NULL
  1425. * - decoding: set by lavc
  1426. */
  1427. uint16_t *intra_matrix;
  1428. /**
  1429. * custom inter quantization matrix
  1430. * - encoding: set by user, can be NULL
  1431. * - decoding: set by lavc
  1432. */
  1433. uint16_t *inter_matrix;
  1434. /**
  1435. * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
  1436. * this is used to workaround some encoder bugs
  1437. * - encoding: unused
  1438. * - decoding: set by user, will be converted to upper case by lavc during init
  1439. */
  1440. unsigned int stream_codec_tag;
  1441. /**
  1442. * scene change detection threshold.
  1443. * 0 is default, larger means fewer detected scene changes
  1444. * - encoding: set by user.
  1445. * - decoding: unused
  1446. */
  1447. int scenechange_threshold;
  1448. /**
  1449. * minimum lagrange multipler
  1450. * - encoding: set by user.
  1451. * - decoding: unused
  1452. */
  1453. int lmin;
  1454. /**
  1455. * maximum lagrange multipler
  1456. * - encoding: set by user.
  1457. * - decoding: unused
  1458. */
  1459. int lmax;
  1460. /**
  1461. * Palette control structure
  1462. * - encoding: ??? (no palette-enabled encoder yet)
  1463. * - decoding: set by user.
  1464. */
  1465. struct AVPaletteControl *palctrl;
  1466. /**
  1467. * noise reduction strength
  1468. * - encoding: set by user.
  1469. * - decoding: unused
  1470. */
  1471. int noise_reduction;
  1472. /**
  1473. * called at the beginning of a frame to get cr buffer for it.
  1474. * buffer type (size, hints) must be the same. lavc won't check it.
  1475. * lavc will pass previous buffer in pic, function should return
  1476. * same buffer or new buffer with old frame "painted" into it.
  1477. * if pic.data[0] == NULL must behave like get_buffer().
  1478. * - encoding: unused
  1479. * - decoding: set by lavc, user can override
  1480. */
  1481. int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
  1482. /**
  1483. * number of bits which should be loaded into the rc buffer before decoding starts
  1484. * - encoding: set by user.
  1485. * - decoding: unused
  1486. */
  1487. int rc_initial_buffer_occupancy;
  1488. /**
  1489. *
  1490. * - encoding: set by user.
  1491. * - decoding: unused
  1492. */
  1493. int inter_threshold;
  1494. /**
  1495. * CODEC_FLAG2_*.
  1496. * - encoding: set by user.
  1497. * - decoding: set by user.
  1498. */
  1499. int flags2;
  1500. /**
  1501. * simulates errors in the bitstream to test error concealment.
  1502. * - encoding: set by user.
  1503. * - decoding: unused.
  1504. */
  1505. int error_rate;
  1506. /**
  1507. * MP3 antialias algorithm, see FF_AA_* below.
  1508. * - encoding: unused
  1509. * - decoding: set by user
  1510. */
  1511. int antialias_algo;
  1512. #define FF_AA_AUTO 0
  1513. #define FF_AA_FASTINT 1 //not implemented yet
  1514. #define FF_AA_INT 2
  1515. #define FF_AA_FLOAT 3
  1516. /**
  1517. * Quantizer noise shaping.
  1518. * - encoding: set by user
  1519. * - decoding: unused
  1520. */
  1521. int quantizer_noise_shaping;
  1522. /**
  1523. * Thread count.
  1524. * is used to decide how many independant tasks should be passed to execute()
  1525. * - encoding: set by user
  1526. * - decoding: set by user
  1527. */
  1528. int thread_count;
  1529. /**
  1530. * the codec may call this to execute several independant things. it will return only after
  1531. * finishing all tasks, the user may replace this with some multithreaded implementation, the
  1532. * default implementation will execute the parts serially
  1533. * @param count the number of things to execute
  1534. * - encoding: set by lavc, user can override
  1535. * - decoding: set by lavc, user can override
  1536. */
  1537. int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
  1538. /**
  1539. * Thread opaque.
  1540. * can be used by execute() to store some per AVCodecContext stuff.
  1541. * - encoding: set by execute()
  1542. * - decoding: set by execute()
  1543. */
  1544. void *thread_opaque;
  1545. /**
  1546. * Motion estimation threshold. under which no motion estimation is
  1547. * performed, but instead the user specified motion vectors are used
  1548. *
  1549. * - encoding: set by user
  1550. * - decoding: unused
  1551. */
  1552. int me_threshold;
  1553. /**
  1554. * Macroblock threshold. under which the user specified macroblock types will be used
  1555. * - encoding: set by user
  1556. * - decoding: unused
  1557. */
  1558. int mb_threshold;
  1559. /**
  1560. * precision of the intra dc coefficient - 8.
  1561. * - encoding: set by user
  1562. * - decoding: unused
  1563. */
  1564. int intra_dc_precision;
  1565. /**
  1566. * noise vs. sse weight for the nsse comparsion function.
  1567. * - encoding: set by user
  1568. * - decoding: unused
  1569. */
  1570. int nsse_weight;
  1571. /**
  1572. * number of macroblock rows at the top which are skipped.
  1573. * - encoding: unused
  1574. * - decoding: set by user
  1575. */
  1576. int skip_top;
  1577. /**
  1578. * number of macroblock rows at the bottom which are skipped.
  1579. * - encoding: unused
  1580. * - decoding: set by user
  1581. */
  1582. int skip_bottom;
  1583. /**
  1584. * profile
  1585. * - encoding: set by user
  1586. * - decoding: set by lavc
  1587. */
  1588. int profile;
  1589. #define FF_PROFILE_UNKNOWN -99
  1590. /**
  1591. * level
  1592. * - encoding: set by user
  1593. * - decoding: set by lavc
  1594. */
  1595. int level;
  1596. #define FF_LEVEL_UNKNOWN -99
  1597. /**
  1598. * low resolution decoding. 1-> 1/2 size, 2->1/4 size
  1599. * - encoding: unused
  1600. * - decoding: set by user
  1601. */
  1602. int lowres;
  1603. /**
  1604. * bitsream width / height. may be different from width/height if lowres
  1605. * or other things are used
  1606. * - encoding: unused
  1607. * - decoding: set by user before init if known, codec should override / dynamically change if needed
  1608. */
  1609. int coded_width, coded_height;
  1610. /**
  1611. * frame skip threshold
  1612. * - encoding: set by user
  1613. * - decoding: unused
  1614. */
  1615. int frame_skip_threshold;
  1616. /**
  1617. * frame skip factor
  1618. * - encoding: set by user
  1619. * - decoding: unused
  1620. */
  1621. int frame_skip_factor;
  1622. /**
  1623. * frame skip exponent
  1624. * - encoding: set by user
  1625. * - decoding: unused
  1626. */
  1627. int frame_skip_exp;
  1628. /**
  1629. * frame skip comparission function
  1630. * - encoding: set by user.
  1631. * - decoding: unused
  1632. */
  1633. int frame_skip_cmp;
  1634. /**
  1635. * border processing masking. raises the quantizer for mbs on the borders
  1636. * of the picture.
  1637. * - encoding: set by user
  1638. * - decoding: unused
  1639. */
  1640. float border_masking;
  1641. /**
  1642. * minimum MB lagrange multipler.
  1643. * - encoding: set by user.
  1644. * - decoding: unused
  1645. */
  1646. int mb_lmin;
  1647. /**
  1648. * maximum MB lagrange multipler.
  1649. * - encoding: set by user.
  1650. * - decoding: unused
  1651. */
  1652. int mb_lmax;
  1653. /**
  1654. *
  1655. * - encoding: set by user.
  1656. * - decoding: unused
  1657. */
  1658. int me_penalty_compensation;
  1659. /**
  1660. *
  1661. * - encoding: unused
  1662. * - decoding: set by user.
  1663. */
  1664. enum AVDiscard skip_loop_filter;
  1665. /**
  1666. *
  1667. * - encoding: unused
  1668. * - decoding: set by user.
  1669. */
  1670. enum AVDiscard skip_idct;
  1671. /**
  1672. *
  1673. * - encoding: unused
  1674. * - decoding: set by user.
  1675. */
  1676. enum AVDiscard skip_frame;
  1677. /**
  1678. *
  1679. * - encoding: set by user.
  1680. * - decoding: unused
  1681. */
  1682. int bidir_refine;
  1683. /**
  1684. *
  1685. * - encoding: set by user.
  1686. * - decoding: unused
  1687. */
  1688. int brd_scale;
  1689. /**
  1690. * constant rate factor - quality-based VBR - values ~correspond to qps
  1691. * - encoding: set by user.
  1692. * - decoding: unused
  1693. */
  1694. int crf;
  1695. /**
  1696. * constant quantization parameter rate control method
  1697. * - encoding: set by user.
  1698. * - decoding: unused
  1699. */
  1700. int cqp;
  1701. /**
  1702. * minimum gop size
  1703. * - encoding: set by user.
  1704. * - decoding: unused
  1705. */
  1706. int keyint_min;
  1707. /**
  1708. * number of reference frames
  1709. * - encoding: set by user.
  1710. * - decoding: unused
  1711. */
  1712. int refs;
  1713. /**
  1714. * chroma qp offset from luma
  1715. * - encoding: set by user.
  1716. * - decoding: unused
  1717. */
  1718. int chromaoffset;
  1719. /**
  1720. * influences how often b-frames are used
  1721. * - encoding: set by user.
  1722. * - decoding: unused
  1723. */
  1724. int bframebias;
  1725. /**
  1726. * trellis RD quantization
  1727. * - encoding: set by user.
  1728. * - decoding: unused
  1729. */
  1730. int trellis;
  1731. /**
  1732. * reduce fluctuations in qp (before curve compression)
  1733. * - encoding: set by user.
  1734. * - decoding: unused
  1735. */
  1736. float complexityblur;
  1737. /**
  1738. * in-loop deblocking filter alphac0 parameter
  1739. * alpha is in the range -6...6
  1740. * - encoding: set by user.
  1741. * - decoding: unused
  1742. */
  1743. int deblockalpha;
  1744. /**
  1745. * in-loop deblocking filter beta parameter
  1746. * beta is in the range -6...6
  1747. * - encoding: set by user.
  1748. * - decoding: unused
  1749. */
  1750. int deblockbeta;
  1751. /**
  1752. * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
  1753. * - encoding: set by user.
  1754. * - decoding: unused
  1755. */
  1756. int partitions;
  1757. #define X264_PART_I4X4 0x001 /* Analyse i4x4 */
  1758. #define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */
  1759. #define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */
  1760. #define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */
  1761. #define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */
  1762. /**
  1763. * direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)
  1764. * - encoding: set by user.
  1765. * - decoding: unused
  1766. */
  1767. int directpred;
  1768. /**
  1769. * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC
  1770. * - encoding: set by user.
  1771. * - decoding: unused
  1772. */
  1773. int cutoff;
  1774. /**
  1775. * multiplied by qscale for each frame and added to scene_change_score
  1776. * - encoding: set by user.
  1777. * - decoding: unused
  1778. */
  1779. int scenechange_factor;
  1780. /**
  1781. *
  1782. * note: value depends upon the compare functin used for fullpel ME
  1783. * - encoding: set by user.
  1784. * - decoding: unused
  1785. */
  1786. int mv0_threshold;
  1787. /**
  1788. * adjusts sensitivity of b_frame_strategy 1
  1789. * - encoding: set by user.
  1790. * - decoding: unused
  1791. */
  1792. int b_sensitivity;
  1793. /**
  1794. * - encoding: set by user.
  1795. * - decoding: unused
  1796. */
  1797. int compression_level;
  1798. #define FF_COMPRESSION_DEFAULT -1
  1799. /**
  1800. * sets whether to use LPC mode - used by FLAC encoder
  1801. * - encoding: set by user.
  1802. * - decoding: unused.
  1803. */
  1804. int use_lpc;
  1805. /**
  1806. * LPC coefficient precision - used by FLAC encoder
  1807. * - encoding: set by user.
  1808. * - decoding: unused.
  1809. */
  1810. int lpc_coeff_precision;
  1811. /**
  1812. * - encoding: set by user.
  1813. * - decoding: unused.
  1814. */
  1815. int min_prediction_order;
  1816. /**
  1817. * - encoding: set by user.
  1818. * - decoding: unused.
  1819. */
  1820. int max_prediction_order;
  1821. /**
  1822. * search method for selecting prediction order
  1823. * - encoding: set by user.
  1824. * - decoding: unused.
  1825. */
  1826. int prediction_order_method;
  1827. /**
  1828. * - encoding: set by user.
  1829. * - decoding: unused.
  1830. */
  1831. int min_partition_order;
  1832. /**
  1833. * - encoding: set by user.
  1834. * - decoding: unused.
  1835. */
  1836. int max_partition_order;
  1837. } AVCodecContext;
  1838. /**
  1839. * AVCodec.
  1840. */
  1841. typedef struct AVCodec {
  1842. const char *name;
  1843. enum CodecType type;
  1844. enum CodecID id;
  1845. int priv_data_size;
  1846. int (*init)(AVCodecContext *);
  1847. int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
  1848. int (*close)(AVCodecContext *);
  1849. int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
  1850. uint8_t *buf, int buf_size);
  1851. int capabilities;
  1852. #if LIBAVCODEC_VERSION_INT < ((50<<16)+(0<<8)+0)
  1853. void *dummy; // FIXME remove next time we break binary compatibility
  1854. #endif
  1855. struct AVCodec *next;
  1856. void (*flush)(AVCodecContext *);
  1857. const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
  1858. const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
  1859. } AVCodec;
  1860. /**
  1861. * four components are given, that's all.
  1862. * the last component is alpha
  1863. */
  1864. typedef struct AVPicture {
  1865. uint8_t *data[4];
  1866. int linesize[4]; ///< number of bytes per line
  1867. } AVPicture;
  1868. /**
  1869. * AVPaletteControl
  1870. * This structure defines a method for communicating palette changes
  1871. * between and demuxer and a decoder.
  1872. */
  1873. #define AVPALETTE_SIZE 1024
  1874. #define AVPALETTE_COUNT 256
  1875. typedef struct AVPaletteControl {
  1876. /* demuxer sets this to 1 to indicate the palette has changed;
  1877. * decoder resets to 0 */
  1878. int palette_changed;
  1879. /* 4-byte ARGB palette entries, stored in native byte order; note that
  1880. * the individual palette components should be on a 8-bit scale; if
  1881. * the palette data comes from a IBM VGA native format, the component
  1882. * data is probably 6 bits in size and needs to be scaled */
  1883. unsigned int palette[AVPALETTE_COUNT];
  1884. } AVPaletteControl;
  1885. typedef struct AVSubtitleRect {
  1886. uint16_t x;
  1887. uint16_t y;
  1888. uint16_t w;
  1889. uint16_t h;
  1890. uint16_t nb_colors;
  1891. int linesize;
  1892. uint32_t *rgba_palette;
  1893. uint8_t *bitmap;
  1894. } AVSubtitleRect;
  1895. typedef struct AVSubtitle {
  1896. uint16_t format; /* 0 = graphics */
  1897. uint32_t start_display_time; /* relative to packet pts, in ms */
  1898. uint32_t end_display_time; /* relative to packet pts, in ms */
  1899. uint32_t num_rects;
  1900. AVSubtitleRect *rects;
  1901. } AVSubtitle;
  1902. extern AVCodec ac3_encoder;
  1903. extern AVCodec mp2_encoder;
  1904. extern AVCodec mp3lame_encoder;
  1905. extern AVCodec oggvorbis_encoder;
  1906. extern AVCodec faac_encoder;
  1907. extern AVCodec flac_encoder;
  1908. extern AVCodec xvid_encoder;
  1909. extern AVCodec mpeg1video_encoder;
  1910. extern AVCodec mpeg2video_encoder;
  1911. extern AVCodec h261_encoder;
  1912. extern AVCodec h263_encoder;
  1913. extern AVCodec h263p_encoder;
  1914. extern AVCodec flv_encoder;
  1915. extern AVCodec rv10_encoder;
  1916. extern AVCodec rv20_encoder;
  1917. extern AVCodec dvvideo_encoder;
  1918. extern AVCodec mjpeg_encoder;
  1919. extern AVCodec ljpeg_encoder;
  1920. extern AVCodec jpegls_encoder;
  1921. extern AVCodec png_encoder;
  1922. extern AVCodec ppm_encoder;
  1923. extern AVCodec pgm_encoder;
  1924. extern AVCodec pgmyuv_encoder;
  1925. extern AVCodec pbm_encoder;
  1926. extern AVCodec pam_encoder;
  1927. extern AVCodec mpeg4_encoder;
  1928. extern AVCodec msmpeg4v1_encoder;
  1929. extern AVCodec msmpeg4v2_encoder;
  1930. extern AVCodec msmpeg4v3_encoder;
  1931. extern AVCodec wmv1_encoder;
  1932. extern AVCodec wmv2_encoder;
  1933. extern AVCodec huffyuv_encoder;
  1934. extern AVCodec ffvhuff_encoder;
  1935. extern AVCodec h264_encoder;
  1936. extern AVCodec asv1_encoder;
  1937. extern AVCodec asv2_encoder;
  1938. extern AVCodec vcr1_encoder;
  1939. extern AVCodec ffv1_encoder;
  1940. extern AVCodec snow_encoder;
  1941. extern AVCodec mdec_encoder;
  1942. extern AVCodec zlib_encoder;
  1943. extern AVCodec sonic_encoder;
  1944. extern AVCodec sonic_ls_encoder;
  1945. extern AVCodec svq1_encoder;
  1946. extern AVCodec x264_encoder;
  1947. extern AVCodec h263_decoder;
  1948. extern AVCodec h261_decoder;
  1949. extern AVCodec mpeg4_decoder;
  1950. extern AVCodec msmpeg4v1_decoder;
  1951. extern AVCodec msmpeg4v2_decoder;
  1952. extern AVCodec msmpeg4v3_decoder;
  1953. extern AVCodec wmv1_decoder;
  1954. extern AVCodec wmv2_decoder;
  1955. extern AVCodec vc1_decoder;
  1956. extern AVCodec wmv3_decoder;
  1957. extern AVCodec mpeg1video_decoder;
  1958. extern AVCodec mpeg2video_decoder;
  1959. extern AVCodec mpegvideo_decoder;
  1960. extern AVCodec mpeg_xvmc_decoder;
  1961. extern AVCodec h263i_decoder;
  1962. extern AVCodec flv_decoder;
  1963. extern AVCodec rv10_decoder;
  1964. extern AVCodec rv20_decoder;
  1965. extern AVCodec rv30_decoder;
  1966. extern AVCodec rv40_decoder;
  1967. extern AVCodec svq1_decoder;
  1968. extern AVCodec svq3_decoder;
  1969. extern AVCodec dvvideo_decoder;
  1970. extern AVCodec wmav1_decoder;
  1971. extern AVCodec wmav2_decoder;
  1972. extern AVCodec mjpeg_decoder;
  1973. extern AVCodec mjpegb_decoder;
  1974. extern AVCodec sp5x_decoder;
  1975. extern AVCodec png_decoder;
  1976. extern AVCodec mp2_decoder;
  1977. extern AVCodec mp3_decoder;
  1978. extern AVCodec mp3adu_decoder;
  1979. extern AVCodec mp3on4_decoder;
  1980. extern AVCodec qdm2_decoder;
  1981. extern AVCodec cook_decoder;
  1982. extern AVCodec truespeech_decoder;
  1983. extern AVCodec tta_decoder;
  1984. extern AVCodec mace3_decoder;
  1985. extern AVCodec mace6_decoder;
  1986. extern AVCodec huffyuv_decoder;
  1987. extern AVCodec ffvhuff_decoder;
  1988. extern AVCodec oggvorbis_decoder;
  1989. extern AVCodec cyuv_decoder;
  1990. extern AVCodec h264_decoder;
  1991. extern AVCodec indeo3_decoder;
  1992. extern AVCodec vp3_decoder;
  1993. extern AVCodec theora_decoder;
  1994. extern AVCodec vp5_decoder;
  1995. extern AVCodec vp6_decoder;
  1996. extern AVCodec vp6f_decoder;
  1997. extern AVCodec amr_nb_decoder;
  1998. extern AVCodec amr_nb_encoder;
  1999. extern AVCodec amr_wb_encoder;
  2000. extern AVCodec amr_wb_decoder;
  2001. extern AVCodec aac_decoder;
  2002. extern AVCodec mpeg4aac_decoder;
  2003. extern AVCodec asv1_decoder;
  2004. extern AVCodec asv2_decoder;
  2005. extern AVCodec vcr1_decoder;
  2006. extern AVCodec cljr_decoder;
  2007. extern AVCodec ffv1_decoder;
  2008. extern AVCodec snow_decoder;
  2009. extern AVCodec fourxm_decoder;
  2010. extern AVCodec mdec_decoder;
  2011. extern AVCodec roq_decoder;
  2012. extern AVCodec interplay_video_decoder;
  2013. extern AVCodec xan_wc3_decoder;
  2014. extern AVCodec rpza_decoder;
  2015. extern AVCodec cinepak_decoder;
  2016. extern AVCodec msrle_decoder;
  2017. extern AVCodec msvideo1_decoder;
  2018. extern AVCodec vqa_decoder;
  2019. extern AVCodec idcin_decoder;
  2020. extern AVCodec eightbps_decoder;
  2021. extern AVCodec smc_decoder;
  2022. extern AVCodec flic_decoder;
  2023. extern AVCodec vmdvideo_decoder;
  2024. extern AVCodec vmdaudio_decoder;
  2025. extern AVCodec truemotion1_decoder;
  2026. extern AVCodec truemotion2_decoder;
  2027. extern AVCodec mszh_decoder;
  2028. extern AVCodec zlib_decoder;
  2029. extern AVCodec ra_144_decoder;
  2030. extern AVCodec ra_288_decoder;
  2031. extern AVCodec roq_dpcm_decoder;
  2032. extern AVCodec interplay_dpcm_decoder;
  2033. extern AVCodec xan_dpcm_decoder;
  2034. extern AVCodec sol_dpcm_decoder;
  2035. extern AVCodec sonic_decoder;
  2036. extern AVCodec qtrle_decoder;
  2037. extern AVCodec flac_decoder;
  2038. extern AVCodec tscc_decoder;
  2039. extern AVCodec cscd_decoder;
  2040. extern AVCodec nuv_decoder;
  2041. extern AVCodec ulti_decoder;
  2042. extern AVCodec qdraw_decoder;
  2043. extern AVCodec xl_decoder;
  2044. extern AVCodec qpeg_decoder;
  2045. extern AVCodec shorten_decoder;
  2046. extern AVCodec loco_decoder;
  2047. extern AVCodec wnv1_decoder;
  2048. extern AVCodec aasc_decoder;
  2049. extern AVCodec alac_decoder;
  2050. extern AVCodec ws_snd1_decoder;
  2051. extern AVCodec indeo2_decoder;
  2052. extern AVCodec vorbis_decoder;
  2053. extern AVCodec fraps_decoder;
  2054. extern AVCodec libgsm_encoder;
  2055. extern AVCodec libgsm_decoder;
  2056. extern AVCodec bmp_decoder;
  2057. extern AVCodec mmvideo_decoder;
  2058. extern AVCodec zmbv_decoder;
  2059. extern AVCodec avs_decoder;
  2060. extern AVCodec smacker_decoder;
  2061. extern AVCodec smackaud_decoder;
  2062. extern AVCodec kmvc_decoder;
  2063. extern AVCodec flashsv_decoder;
  2064. extern AVCodec cavs_decoder;
  2065. extern AVCodec vmnc_decoder;
  2066. /* pcm codecs */
  2067. #define PCM_CODEC(id, name) \
  2068. extern AVCodec name ## _decoder; \
  2069. extern AVCodec name ## _encoder
  2070. PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
  2071. PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
  2072. PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
  2073. PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
  2074. PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
  2075. PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
  2076. PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
  2077. PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
  2078. PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
  2079. PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
  2080. PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
  2081. PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
  2082. PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
  2083. PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
  2084. PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
  2085. PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
  2086. PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
  2087. /* adpcm codecs */
  2088. PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
  2089. PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
  2090. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
  2091. PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
  2092. PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
  2093. PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
  2094. PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
  2095. PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
  2096. PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
  2097. PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
  2098. PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
  2099. PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
  2100. PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
  2101. PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
  2102. PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
  2103. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
  2104. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
  2105. PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
  2106. #undef PCM_CODEC
  2107. /* dummy raw video codec */
  2108. extern AVCodec rawvideo_encoder;
  2109. extern AVCodec rawvideo_decoder;
  2110. /* the following codecs use external GPL libs */
  2111. extern AVCodec ac3_decoder;
  2112. extern AVCodec dts_decoder;
  2113. /* subtitles */
  2114. extern AVCodec dvdsub_encoder;
  2115. extern AVCodec dvdsub_decoder;
  2116. extern AVCodec dvbsub_encoder;
  2117. extern AVCodec dvbsub_decoder;
  2118. /* resample.c */
  2119. struct ReSampleContext;
  2120. struct AVResampleContext;
  2121. typedef struct ReSampleContext ReSampleContext;
  2122. ReSampleContext *audio_resample_init(int output_channels, int input_channels,
  2123. int output_rate, int input_rate);
  2124. int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
  2125. void audio_resample_close(ReSampleContext *s);
  2126. struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
  2127. int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
  2128. void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
  2129. void av_resample_close(struct AVResampleContext *c);
  2130. /* YUV420 format is assumed ! */
  2131. struct ImgReSampleContext;
  2132. typedef struct ImgReSampleContext ImgReSampleContext;
  2133. ImgReSampleContext *img_resample_init(int output_width, int output_height,
  2134. int input_width, int input_height);
  2135. ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
  2136. int iwidth, int iheight,
  2137. int topBand, int bottomBand,
  2138. int leftBand, int rightBand,
  2139. int padtop, int padbottom,
  2140. int padleft, int padright);
  2141. void img_resample(ImgReSampleContext *s,
  2142. AVPicture *output, const AVPicture *input);
  2143. void img_resample_close(ImgReSampleContext *s);
  2144. /**
  2145. * Allocate memory for a picture. Call avpicture_free to free it.
  2146. *
  2147. * @param picture the picture to be filled in.
  2148. * @param pix_fmt the format of the picture.
  2149. * @param width the width of the picture.
  2150. * @param height the height of the picture.
  2151. * @return 0 if successful, -1 if not.
  2152. */
  2153. int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
  2154. /* Free a picture previously allocated by avpicture_alloc. */
  2155. void avpicture_free(AVPicture *picture);
  2156. int avpicture_fill(AVPicture *picture, uint8_t *ptr,
  2157. int pix_fmt, int width, int height);
  2158. int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
  2159. unsigned char *dest, int dest_size);
  2160. int avpicture_get_size(int pix_fmt, int width, int height);
  2161. void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
  2162. const char *avcodec_get_pix_fmt_name(int pix_fmt);
  2163. void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
  2164. enum PixelFormat avcodec_get_pix_fmt(const char* name);
  2165. unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
  2166. #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
  2167. #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
  2168. #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
  2169. #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
  2170. #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
  2171. #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
  2172. int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
  2173. int has_alpha);
  2174. int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
  2175. int has_alpha, int *loss_ptr);
  2176. #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
  2177. #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
  2178. int img_get_alpha_info(const AVPicture *src,
  2179. int pix_fmt, int width, int height);
  2180. /* convert among pixel formats */
  2181. int img_convert(AVPicture *dst, int dst_pix_fmt,
  2182. const AVPicture *src, int pix_fmt,
  2183. int width, int height);
  2184. /* deinterlace a picture */
  2185. int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
  2186. int pix_fmt, int width, int height);
  2187. /* external high level API */
  2188. extern AVCodec *first_avcodec;
  2189. /* returns LIBAVCODEC_VERSION_INT constant */
  2190. unsigned avcodec_version(void);
  2191. /* returns LIBAVCODEC_BUILD constant */
  2192. unsigned avcodec_build(void);
  2193. void avcodec_init(void);
  2194. void register_avcodec(AVCodec *format);
  2195. AVCodec *avcodec_find_encoder(enum CodecID id);
  2196. AVCodec *avcodec_find_encoder_by_name(const char *name);
  2197. AVCodec *avcodec_find_decoder(enum CodecID id);
  2198. AVCodec *avcodec_find_decoder_by_name(const char *name);
  2199. void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
  2200. void avcodec_get_context_defaults(AVCodecContext *s);
  2201. AVCodecContext *avcodec_alloc_context(void);
  2202. void avcodec_get_frame_defaults(AVFrame *pic);
  2203. AVFrame *avcodec_alloc_frame(void);
  2204. int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
  2205. void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
  2206. int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
  2207. void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
  2208. int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
  2209. enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
  2210. int avcodec_thread_init(AVCodecContext *s, int thread_count);
  2211. void avcodec_thread_free(AVCodecContext *s);
  2212. int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2213. int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
  2214. //FIXME func typedef
  2215. /**
  2216. * opens / inits the AVCodecContext.
  2217. * not thread save!
  2218. */
  2219. int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
  2220. /**
  2221. * Decode an audio frame.
  2222. *
  2223. * @param avctx the codec context.
  2224. * @param samples output buffer, 16 byte aligned
  2225. * @param frame_size_ptr the output buffer size in bytes, zero if no frame could be compressed
  2226. * @param buf input buffer, 16 byte aligned
  2227. * @param buf_size the input buffer size
  2228. * @return 0 if successful, -1 if not.
  2229. */
  2230. int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
  2231. int *frame_size_ptr,
  2232. uint8_t *buf, int buf_size);
  2233. int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
  2234. int *got_picture_ptr,
  2235. uint8_t *buf, int buf_size);
  2236. int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
  2237. int *got_sub_ptr,
  2238. const uint8_t *buf, int buf_size);
  2239. int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
  2240. int *data_size_ptr,
  2241. uint8_t *buf, int buf_size);
  2242. int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2243. const short *samples);
  2244. int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2245. const AVFrame *pict);
  2246. int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
  2247. const AVSubtitle *sub);
  2248. int avcodec_close(AVCodecContext *avctx);
  2249. void avcodec_register_all(void);
  2250. void avcodec_flush_buffers(AVCodecContext *avctx);
  2251. void avcodec_default_free_buffers(AVCodecContext *s);
  2252. /* misc usefull functions */
  2253. /**
  2254. * returns a single letter to describe the picture type
  2255. */
  2256. char av_get_pict_type_char(int pict_type);
  2257. /**
  2258. * returns codec bits per sample
  2259. */
  2260. int av_get_bits_per_sample(enum CodecID codec_id);
  2261. /* frame parsing */
  2262. typedef struct AVCodecParserContext {
  2263. void *priv_data;
  2264. struct AVCodecParser *parser;
  2265. int64_t frame_offset; /* offset of the current frame */
  2266. int64_t cur_offset; /* current offset
  2267. (incremented by each av_parser_parse()) */
  2268. int64_t last_frame_offset; /* offset of the last frame */
  2269. /* video info */
  2270. int pict_type; /* XXX: put it back in AVCodecContext */
  2271. int repeat_pict; /* XXX: put it back in AVCodecContext */
  2272. int64_t pts; /* pts of the current frame */
  2273. int64_t dts; /* dts of the current frame */
  2274. /* private data */
  2275. int64_t last_pts;
  2276. int64_t last_dts;
  2277. int fetch_timestamp;
  2278. #define AV_PARSER_PTS_NB 4
  2279. int cur_frame_start_index;
  2280. int64_t cur_frame_offset[AV_PARSER_PTS_NB];
  2281. int64_t cur_frame_pts[AV_PARSER_PTS_NB];
  2282. int64_t cur_frame_dts[AV_PARSER_PTS_NB];
  2283. int flags;
  2284. #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
  2285. } AVCodecParserContext;
  2286. typedef struct AVCodecParser {
  2287. int codec_ids[5]; /* several codec IDs are permitted */
  2288. int priv_data_size;
  2289. int (*parser_init)(AVCodecParserContext *s);
  2290. int (*parser_parse)(AVCodecParserContext *s,
  2291. AVCodecContext *avctx,
  2292. uint8_t **poutbuf, int *poutbuf_size,
  2293. const uint8_t *buf, int buf_size);
  2294. void (*parser_close)(AVCodecParserContext *s);
  2295. int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
  2296. struct AVCodecParser *next;
  2297. } AVCodecParser;
  2298. extern AVCodecParser *av_first_parser;
  2299. void av_register_codec_parser(AVCodecParser *parser);
  2300. AVCodecParserContext *av_parser_init(int codec_id);
  2301. int av_parser_parse(AVCodecParserContext *s,
  2302. AVCodecContext *avctx,
  2303. uint8_t **poutbuf, int *poutbuf_size,
  2304. const uint8_t *buf, int buf_size,
  2305. int64_t pts, int64_t dts);
  2306. int av_parser_change(AVCodecParserContext *s,
  2307. AVCodecContext *avctx,
  2308. uint8_t **poutbuf, int *poutbuf_size,
  2309. const uint8_t *buf, int buf_size, int keyframe);
  2310. void av_parser_close(AVCodecParserContext *s);
  2311. extern AVCodecParser mpegvideo_parser;
  2312. extern AVCodecParser mpeg4video_parser;
  2313. extern AVCodecParser cavsvideo_parser;
  2314. extern AVCodecParser h261_parser;
  2315. extern AVCodecParser h263_parser;
  2316. extern AVCodecParser h264_parser;
  2317. extern AVCodecParser mjpeg_parser;
  2318. extern AVCodecParser pnm_parser;
  2319. extern AVCodecParser mpegaudio_parser;
  2320. extern AVCodecParser ac3_parser;
  2321. extern AVCodecParser dvdsub_parser;
  2322. extern AVCodecParser dvbsub_parser;
  2323. extern AVCodecParser aac_parser;
  2324. typedef struct AVBitStreamFilterContext {
  2325. void *priv_data;
  2326. struct AVBitStreamFilter *filter;
  2327. AVCodecParserContext *parser;
  2328. struct AVBitStreamFilterContext *next;
  2329. } AVBitStreamFilterContext;
  2330. typedef struct AVBitStreamFilter {
  2331. const char *name;
  2332. int priv_data_size;
  2333. int (*filter)(AVBitStreamFilterContext *bsfc,
  2334. AVCodecContext *avctx, const char *args,
  2335. uint8_t **poutbuf, int *poutbuf_size,
  2336. const uint8_t *buf, int buf_size, int keyframe);
  2337. struct AVBitStreamFilter *next;
  2338. } AVBitStreamFilter;
  2339. extern AVBitStreamFilter *av_first_bitstream_filter;
  2340. void av_register_bitstream_filter(AVBitStreamFilter *bsf);
  2341. AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
  2342. int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
  2343. AVCodecContext *avctx, const char *args,
  2344. uint8_t **poutbuf, int *poutbuf_size,
  2345. const uint8_t *buf, int buf_size, int keyframe);
  2346. void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
  2347. extern AVBitStreamFilter dump_extradata_bsf;
  2348. extern AVBitStreamFilter remove_extradata_bsf;
  2349. extern AVBitStreamFilter noise_bsf;
  2350. /* memory */
  2351. void *av_mallocz(unsigned int size);
  2352. char *av_strdup(const char *s);
  2353. void av_freep(void *ptr);
  2354. void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
  2355. /* for static data only */
  2356. /* call av_free_static to release all staticaly allocated tables */
  2357. void av_free_static(void);
  2358. void *av_mallocz_static(unsigned int size);
  2359. void *av_realloc_static(void *ptr, unsigned int size);
  2360. void img_copy(AVPicture *dst, const AVPicture *src,
  2361. int pix_fmt, int width, int height);
  2362. int img_crop(AVPicture *dst, const AVPicture *src,
  2363. int pix_fmt, int top_band, int left_band);
  2364. int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
  2365. int padtop, int padbottom, int padleft, int padright, int *color);
  2366. /* endian macros */
  2367. #if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
  2368. #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
  2369. #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
  2370. (((uint8_t*)(x))[1] << 16) | \
  2371. (((uint8_t*)(x))[2] << 8) | \
  2372. ((uint8_t*)(x))[3])
  2373. #define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
  2374. #define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
  2375. (((uint8_t*)(x))[2] << 16) | \
  2376. (((uint8_t*)(x))[1] << 8) | \
  2377. ((uint8_t*)(x))[0])
  2378. #endif
  2379. extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  2380. #ifdef __cplusplus
  2381. }
  2382. #endif
  2383. #endif /* AVCODEC_H */