FFMPeg代码分析:AVCodecContext结构体

转自:http://blog.csdn.net/shaqoneal/article/details/16941235

在调用avformat_open_input打开文件后,下一步调用av_find_stream_info函数从文件中读取音视频流的信息,而后AVFormatContext的结构体将会将这些信息保存在其中。在找到AVFormatContext的视频stream后,获取其codec保存到指向AVCodecContext的指针:

  1. // Find the first video stream    
  2. for(i=0; i<pFormatCtx->nb_streams; i++)    
  3. {    
  4.     if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && videoStream<0)  
  5.     {    
  6.         videoStream=i;    
  7.     }    
  8. }    
  9. if(videoStream==-1)    
  10.   return -1; // Didn't find a video stream    
  11.   
  12. // Get a pointer to the codec context for the video stream    
  13.   
  14. pCodecCtx=pFormatCtx->streams[videoStream]->codec;    
编解码器上下文AVCodecContext的定义如下:
  1. typedef struct AVCodecContext {  
  2.      
  3.     const AVClass *av_class;//当前结构体的“基类”  
  4.     int log_level_offset;  
  5.   
  6.     enum AVMediaType codec_type; //媒体类型,主要有AVMEDIA_TYPE_VIDEO视频、AVMEDIA_TYPE_AUDIO音频、AVMEDIA_TYPE_SUBTITLE字幕等  
  7.     const struct AVCodec  *codec;//编解码器结构体  
  8.     char             codec_name[32];  
  9.     enum AVCodecID     codec_id; //枚举变量,标识编解码器的id,例如AV_CODEC_ID_MPEG2VIDEO、AV_CODEC_ID_H264、AV_CODEC_ID_HEVC等  
  10.   
  11.     unsigned int codec_tag;  
  12.    
  13.     unsigned int stream_codec_tag;  
  14.   
  15.     void *priv_data;  
  16.    
  17.     struct AVCodecInternal *internal;  
  18.    
  19.     void *opaque;  
  20.    
  21.     int bit_rate;//平均码率,解码时由libavcodec设定  
  22.   
  23.     int bit_rate_tolerance;  
  24.   
  25.     int global_quality;  
  26.    
  27.     int compression_level;  
  28. #define FF_COMPRESSION_DEFAULT -1  
  29.    
  30.     int flags;  
  31.    
  32.     int flags2;  
  33.    
  34.     uint8_t *extradata;//保存编解码器的附加信息,如参数集合等  
  35.     int extradata_size;  
  36.    
  37.     AVRational time_base;//用于时间转换的参数  
  38.   
  39.     int ticks_per_frame;  
  40.    
  41.     int delay;  
  42.    
  43.     int width, height;//视频的分辨率  
  44.   
  45.     
  46.     int coded_width, coded_height;  
  47.   
  48. #define FF_ASPECT_EXTENDED 15  
  49.   
  50.     int gop_size;//编码时图像组的长度;  
  51.   
  52.     enum AVPixelFormat pix_fmt;//图像像素的格式,例如AV_PIX_FMT_YUV420P、AV_PIX_FMT_YUYV422、AV_PIX_FMT_RGB24等  
  53.   
  54.     int me_method;//编码所采用的运动搜索算法  
  55.   
  56.     void (*draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],int y, int type, int height);  
  57.   
  58.     enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);  
  59.   
  60.     int max_b_frames;//最大b帧数  
  61.   
  62.     float b_quant_factor;  
  63.   
  64.     /** obsolete FIXME remove */  
  65.     int rc_strategy;  
  66. #define FF_RC_STRATEGY_XVID 1  
  67.   
  68.     int b_frame_strategy;  
  69.    
  70.     float b_quant_offset;  
  71.   
  72.     int has_b_frames;  
  73.   
  74.     int mpeg_quant;  
  75.   
  76.     float i_quant_factor;  
  77.   
  78.     float i_quant_offset;  
  79.   
  80.     float lumi_masking;  
  81.   
  82.     float temporal_cplx_masking;  
  83.   
  84.     float spatial_cplx_masking;  
  85.   
  86.     float p_masking;  
  87.   
  88.     float dark_masking;  
  89.   
  90.     int slice_count;//条带数目  
  91.   
  92.      int prediction_method;  
  93. #define FF_PRED_LEFT   0  
  94. #define FF_PRED_PLANE  1  
  95. #define FF_PRED_MEDIAN 2  
  96.   
  97.   
  98.     int *slice_offset;  
  99.   
  100.     AVRational sample_aspect_ratio;  
  101.   
  102.     int me_cmp;  
  103.   
  104.     int me_sub_cmp;  
  105.   
  106.     int mb_cmp;  
  107.   
  108.     int ildct_cmp;  
  109. #define FF_CMP_SAD    0  
  110. #define FF_CMP_SSE    1  
  111. #define FF_CMP_SATD   2  
  112. #define FF_CMP_DCT    3  
  113. #define FF_CMP_PSNR   4  
  114. #define FF_CMP_BIT    5  
  115. #define FF_CMP_RD     6  
  116. #define FF_CMP_ZERO   7  
  117. #define FF_CMP_VSAD   8  
  118. #define FF_CMP_VSSE   9  
  119. #define FF_CMP_NSSE   10  
  120. #define FF_CMP_W53    11  
  121. #define FF_CMP_W97    12  
  122. #define FF_CMP_DCTMAX 13  
  123. #define FF_CMP_DCT264 14  
  124. #define FF_CMP_CHROMA 256  
  125.   
  126.   
  127.     int dia_size;  
  128.   
  129.     int last_predictor_count;  
  130.   
  131.     int pre_me;  
  132.   
  133.     int me_pre_cmp;  
  134.   
  135.     int pre_dia_size;  
  136.   
  137.     int me_subpel_quality;  
  138.   
  139.     int dtg_active_format;  
  140. #define FF_DTG_AFD_SAME         8  
  141. #define FF_DTG_AFD_4_3          9  
  142. #define FF_DTG_AFD_16_9         10  
  143. #define FF_DTG_AFD_14_9         11  
  144. #define FF_DTG_AFD_4_3_SP_14_9  13  
  145. #define FF_DTG_AFD_16_9_SP_14_9 14  
  146. #define FF_DTG_AFD_SP_4_3       15  
  147.   
  148.     int me_range;  
  149.   
  150.     int intra_quant_bias;  
  151. #define FF_DEFAULT_QUANT_BIAS 999999  
  152.   
  153.     int inter_quant_bias;  
  154.   
  155.     int slice_flags;  
  156. #define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display  
  157. #define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)  
  158. #define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)  
  159.   
  160.   
  161.     int xvmc_acceleration;  
  162.   
  163.   
  164.     int mb_decision;  
  165. #define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp  
  166. #define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits  
  167. #define FF_MB_DECISION_RD     2        ///< rate distortion  
  168.   
  169.     /** 
  170.      * custom intra quantization matrix 
  171.      * - encoding: Set by user, can be NULL. 
  172.      * - decoding: Set by libavcodec. 
  173.      */  
  174.     uint16_t *intra_matrix;  
  175.   
  176.     /** 
  177.      * custom inter quantization matrix 
  178.      * - encoding: Set by user, can be NULL. 
  179.      * - decoding: Set by libavcodec. 
  180.      */  
  181.     uint16_t *inter_matrix;  
  182.   
  183.     /** 
  184.      * scene change detection threshold 
  185.      * 0 is default, larger means fewer detected scene changes. 
  186.      * - encoding: Set by user. 
  187.      * - decoding: unused 
  188.      */  
  189.     int scenechange_threshold;  
  190.   
  191.     /** 
  192.      * noise reduction strength 
  193.      * - encoding: Set by user. 
  194.      * - decoding: unused 
  195.      */  
  196.     int noise_reduction;  
  197.   
  198.     /** 
  199.      * Motion estimation threshold below which no motion estimation is 
  200.      * performed, but instead the user specified motion vectors are used. 
  201.      * 
  202.      * - encoding: Set by user. 
  203.      * - decoding: unused 
  204.      */  
  205.     int me_threshold;  
  206.   
  207.     /** 
  208.      * Macroblock threshold below which the user specified macroblock types will be used. 
  209.      * - encoding: Set by user. 
  210.      * - decoding: unused 
  211.      */  
  212.     int mb_threshold;  
  213.   
  214.     /** 
  215.      * precision of the intra DC coefficient - 8 
  216.      * - encoding: Set by user. 
  217.      * - decoding: unused 
  218.      */  
  219.     int intra_dc_precision;  
  220.   
  221.     /** 
  222.      * Number of macroblock rows at the top which are skipped. 
  223.      * - encoding: unused 
  224.      * - decoding: Set by user. 
  225.      */  
  226.     int skip_top;  
  227.   
  228.     /** 
  229.      * Number of macroblock rows at the bottom which are skipped. 
  230.      * - encoding: unused 
  231.      * - decoding: Set by user. 
  232.      */  
  233.     int skip_bottom;  
  234.   
  235.     /** 
  236.      * Border processing masking, raises the quantizer for mbs on the borders 
  237.      * of the picture. 
  238.      * - encoding: Set by user. 
  239.      * - decoding: unused 
  240.      */  
  241.     float border_masking;  
  242.   
  243.     /** 
  244.      * minimum MB lagrange multipler 
  245.      * - encoding: Set by user. 
  246.      * - decoding: unused 
  247.      */  
  248.     int mb_lmin;  
  249.   
  250.     /** 
  251.      * maximum MB lagrange multipler 
  252.      * - encoding: Set by user. 
  253.      * - decoding: unused 
  254.      */  
  255.     int mb_lmax;  
  256.   
  257.     /** 
  258.      * 
  259.      * - encoding: Set by user. 
  260.      * - decoding: unused 
  261.      */  
  262.     int me_penalty_compensation;  
  263.   
  264.     /** 
  265.      * 
  266.      * - encoding: Set by user. 
  267.      * - decoding: unused 
  268.      */  
  269.     int bidir_refine;  
  270.   
  271.     /** 
  272.      * 
  273.      * - encoding: Set by user. 
  274.      * - decoding: unused 
  275.      */  
  276.     int brd_scale;  
  277.   
  278.     /** 
  279.      * minimum GOP size 
  280.      * - encoding: Set by user. 
  281.      * - decoding: unused 
  282.      */  
  283.     int keyint_min;  
  284.   
  285.     /** 
  286.      * number of reference frames 
  287.      * - encoding: Set by user. 
  288.      * - decoding: Set by lavc. 
  289.      */  
  290.     int refs;  
  291.   
  292.     /** 
  293.      * chroma qp offset from luma 
  294.      * - encoding: Set by user. 
  295.      * - decoding: unused 
  296.      */  
  297.     int chromaoffset;  
  298.   
  299.     /** 
  300.      * Multiplied by qscale for each frame and added to scene_change_score. 
  301.      * - encoding: Set by user. 
  302.      * - decoding: unused 
  303.      */  
  304.     int scenechange_factor;  
  305.   
  306.     /** 
  307.      * 
  308.      * Note: Value depends upon the compare function used for fullpel ME. 
  309.      * - encoding: Set by user. 
  310.      * - decoding: unused 
  311.      */  
  312.     int mv0_threshold;  
  313.   
  314.     /** 
  315.      * Adjust sensitivity of b_frame_strategy 1. 
  316.      * - encoding: Set by user. 
  317.      * - decoding: unused 
  318.      */  
  319.     int b_sensitivity;  
  320.   
  321.     /** 
  322.      * Chromaticity coordinates of the source primaries. 
  323.      * - encoding: Set by user 
  324.      * - decoding: Set by libavcodec 
  325.      */  
  326.     enum AVColorPrimaries color_primaries;  
  327.   
  328.     /** 
  329.      * Color Transfer Characteristic. 
  330.      * - encoding: Set by user 
  331.      * - decoding: Set by libavcodec 
  332.      */  
  333.     enum AVColorTransferCharacteristic color_trc;  
  334.   
  335.     /** 
  336.      * YUV colorspace type. 
  337.      * - encoding: Set by user 
  338.      * - decoding: Set by libavcodec 
  339.      */  
  340.     enum AVColorSpace colorspace;  
  341.   
  342.     /** 
  343.      * MPEG vs JPEG YUV range. 
  344.      * - encoding: Set by user 
  345.      * - decoding: Set by libavcodec 
  346.      */  
  347.     enum AVColorRange color_range;  
  348.   
  349.     /** 
  350.      * This defines the location of chroma samples. 
  351.      * - encoding: Set by user 
  352.      * - decoding: Set by libavcodec 
  353.      */  
  354.     enum AVChromaLocation chroma_sample_location;  
  355.   
  356.     /** 
  357.      * Number of slices. 
  358.      * Indicates number of picture subdivisions. Used for parallelized 
  359.      * decoding. 
  360.      * - encoding: Set by user 
  361.      * - decoding: unused 
  362.      */  
  363.     int slices;  
  364.   
  365.     /** Field order 
  366.      * - encoding: set by libavcodec 
  367.      * - decoding: Set by user. 
  368.      */  
  369.     enum AVFieldOrder field_order;  
  370.   
  371.     /* audio only */  
  372.     int sample_rate; ///< samples per second  
  373.     int channels;    ///< number of audio channels  
  374.   
  375.     /** 
  376.      * audio sample format 
  377.      * - encoding: Set by user. 
  378.      * - decoding: Set by libavcodec. 
  379.      */  
  380.     enum AVSampleFormat sample_fmt;  ///< sample format  
  381.   
  382.     /* The following data should not be initialized. */  
  383.     /** 
  384.      * Number of samples per channel in an audio frame. 
  385.      * 
  386.      * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame 
  387.      *   except the last must contain exactly frame_size samples per channel. 
  388.      *   May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the 
  389.      *   frame size is not restricted. 
  390.      * - decoding: may be set by some decoders to indicate constant frame size 
  391.      */  
  392.     int frame_size;  
  393.   
  394.     /** 
  395.      * Frame counter, set by libavcodec. 
  396.      * 
  397.      * - decoding: total number of frames returned from the decoder so far. 
  398.      * - encoding: total number of frames passed to the encoder so far. 
  399.      * 
  400.      *   @note the counter is not incremented if encoding/decoding resulted in 
  401.      *   an error. 
  402.      */  
  403.     int frame_number;  
  404.   
  405.     /** 
  406.      * number of bytes per packet if constant and known or 0 
  407.      * Used by some WAV based audio codecs. 
  408.      */  
  409.     int block_align;  
  410.   
  411.     /** 
  412.      * Audio cutoff bandwidth (0 means "automatic") 
  413.      * - encoding: Set by user. 
  414.      * - decoding: unused 
  415.      */  
  416.     int cutoff;  
  417.   
  418. #if FF_API_REQUEST_CHANNELS  
  419.     /** 
  420.      * Decoder should decode to this many channels if it can (0 for default) 
  421.      * - encoding: unused 
  422.      * - decoding: Set by user. 
  423.      * @deprecated Deprecated in favor of request_channel_layout. 
  424.      */  
  425.     attribute_deprecated int request_channels;  
  426. #endif  
  427.   
  428.     /** 
  429.      * Audio channel layout. 
  430.      * - encoding: set by user. 
  431.      * - decoding: set by user, may be overwritten by libavcodec. 
  432.      */  
  433.     uint64_t channel_layout;  
  434.   
  435.     /** 
  436.      * Request decoder to use this channel layout if it can (0 for default) 
  437.      * - encoding: unused 
  438.      * - decoding: Set by user. 
  439.      */  
  440.     uint64_t request_channel_layout;  
  441.   
  442.     /** 
  443.      * Type of service that the audio stream conveys. 
  444.      * - encoding: Set by user. 
  445.      * - decoding: Set by libavcodec. 
  446.      */  
  447.     enum AVAudioServiceType audio_service_type;  
  448.   
  449.     /** 
  450.      * desired sample format 
  451.      * - encoding: Not used. 
  452.      * - decoding: Set by user. 
  453.      * Decoder will decode to this format if it can. 
  454.      */  
  455.     enum AVSampleFormat request_sample_fmt;  
  456.   
  457. #if FF_API_GET_BUFFER  
  458.     /** 
  459.      * Called at the beginning of each frame to get a buffer for it. 
  460.      * 
  461.      * The function will set AVFrame.data[], AVFrame.linesize[]. 
  462.      * AVFrame.extended_data[] must also be set, but it should be the same as 
  463.      * AVFrame.data[] except for planar audio with more channels than can fit 
  464.      * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as 
  465.      * many data pointers as it can hold. 
  466.      * 
  467.      * if CODEC_CAP_DR1 is not set then get_buffer() must call 
  468.      * avcodec_default_get_buffer() instead of providing buffers allocated by 
  469.      * some other means. 
  470.      * 
  471.      * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't 
  472.      * need it. avcodec_default_get_buffer() aligns the output buffer properly, 
  473.      * but if get_buffer() is overridden then alignment considerations should 
  474.      * be taken into account. 
  475.      * 
  476.      * @see avcodec_default_get_buffer() 
  477.      * 
  478.      * Video: 
  479.      * 
  480.      * If pic.reference is set then the frame will be read later by libavcodec. 
  481.      * avcodec_align_dimensions2() should be used to find the required width and 
  482.      * height, as they normally need to be rounded up to the next multiple of 16. 
  483.      * 
  484.      * If frame multithreading is used and thread_safe_callbacks is set, 
  485.      * it may be called from a different thread, but not from more than one at 
  486.      * once. Does not need to be reentrant. 
  487.      * 
  488.      * @see release_buffer(), reget_buffer() 
  489.      * @see avcodec_align_dimensions2() 
  490.      * 
  491.      * Audio: 
  492.      * 
  493.      * Decoders request a buffer of a particular size by setting 
  494.      * AVFrame.nb_samples prior to calling get_buffer(). The decoder may, 
  495.      * however, utilize only part of the buffer by setting AVFrame.nb_samples 
  496.      * to a smaller value in the output frame. 
  497.      * 
  498.      * Decoders cannot use the buffer after returning from 
  499.      * avcodec_decode_audio4(), so they will not call release_buffer(), as it 
  500.      * is assumed to be released immediately upon return. In some rare cases, 
  501.      * a decoder may need to call get_buffer() more than once in a single 
  502.      * call to avcodec_decode_audio4(). In that case, when get_buffer() is 
  503.      * called again after it has already been called once, the previously 
  504.      * acquired buffer is assumed to be released at that time and may not be 
  505.      * reused by the decoder. 
  506.      * 
  507.      * As a convenience, av_samples_get_buffer_size() and 
  508.      * av_samples_fill_arrays() in libavutil may be used by custom get_buffer() 
  509.      * functions to find the required data size and to fill data pointers and 
  510.      * linesize. In AVFrame.linesize, only linesize[0] may be set for audio 
  511.      * since all planes must be the same size. 
  512.      * 
  513.      * @see av_samples_get_buffer_size(), av_samples_fill_arrays() 
  514.      * 
  515.      * - encoding: unused 
  516.      * - decoding: Set by libavcodec, user can override. 
  517.      * 
  518.      * @deprecated use get_buffer2() 
  519.      */  
  520.     attribute_deprecated  
  521.     int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);  
  522.   
  523.     /** 
  524.      * Called to release buffers which were allocated with get_buffer. 
  525.      * A released buffer can be reused in get_buffer(). 
  526.      * pic.data[*] must be set to NULL. 
  527.      * May be called from a different thread if frame multithreading is used, 
  528.      * but not by more than one thread at once, so does not need to be reentrant. 
  529.      * - encoding: unused 
  530.      * - decoding: Set by libavcodec, user can override. 
  531.      * 
  532.      * @deprecated custom freeing callbacks should be set from get_buffer2() 
  533.      */  
  534.     attribute_deprecated  
  535.     void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);  
  536.   
  537.     /** 
  538.      * Called at the beginning of a frame to get cr buffer for it. 
  539.      * Buffer type (size, hints) must be the same. libavcodec won't check it. 
  540.      * libavcodec will pass previous buffer in pic, function should return 
  541.      * same buffer or new buffer with old frame "painted" into it. 
  542.      * If pic.data[0] == NULL must behave like get_buffer(). 
  543.      * if CODEC_CAP_DR1 is not set then reget_buffer() must call 
  544.      * avcodec_default_reget_buffer() instead of providing buffers allocated by 
  545.      * some other means. 
  546.      * - encoding: unused 
  547.      * - decoding: Set by libavcodec, user can override. 
  548.      */  
  549.     attribute_deprecated  
  550.     int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);  
  551. #endif  
  552.   
  553.     /** 
  554.      * This callback is called at the beginning of each frame to get data 
  555.      * buffer(s) for it. There may be one contiguous buffer for all the data or 
  556.      * there may be a buffer per each data plane or anything in between. What 
  557.      * this means is, you may set however many entries in buf[] you feel necessary. 
  558.      * Each buffer must be reference-counted using the AVBuffer API (see description 
  559.      * of buf[] below). 
  560.      * 
  561.      * The following fields will be set in the frame before this callback is 
  562.      * called: 
  563.      * - format 
  564.      * - width, height (video only) 
  565.      * - sample_rate, channel_layout, nb_samples (audio only) 
  566.      * Their values may differ from the corresponding values in 
  567.      * AVCodecContext. This callback must use the frame values, not the codec 
  568.      * context values, to calculate the required buffer size. 
  569.      * 
  570.      * This callback must fill the following fields in the frame: 
  571.      * - data[] 
  572.      * - linesize[] 
  573.      * - extended_data: 
  574.      *   * if the data is planar audio with more than 8 channels, then this 
  575.      *     callback must allocate and fill extended_data to contain all pointers 
  576.      *     to all data planes. data[] must hold as many pointers as it can. 
  577.      *     extended_data must be allocated with av_malloc() and will be freed in 
  578.      *     av_frame_unref(). 
  579.      *   * otherwise exended_data must point to data 
  580.      * - buf[] must contain one or more pointers to AVBufferRef structures. Each of 
  581.      *   the frame's data and extended_data pointers must be contained in these. That 
  582.      *   is, one AVBufferRef for each allocated chunk of memory, not necessarily one 
  583.      *   AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(), 
  584.      *   and av_buffer_ref(). 
  585.      * - extended_buf and nb_extended_buf must be allocated with av_malloc() by 
  586.      *   this callback and filled with the extra buffers if there are more 
  587.      *   buffers than buf[] can hold. extended_buf will be freed in 
  588.      *   av_frame_unref(). 
  589.      * 
  590.      * If CODEC_CAP_DR1 is not set then get_buffer2() must call 
  591.      * avcodec_default_get_buffer2() instead of providing buffers allocated by 
  592.      * some other means. 
  593.      * 
  594.      * Each data plane must be aligned to the maximum required by the target 
  595.      * CPU. 
  596.      * 
  597.      * @see avcodec_default_get_buffer2() 
  598.      * 
  599.      * Video: 
  600.      * 
  601.      * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused 
  602.      * (read and/or written to if it is writable) later by libavcodec. 
  603.      * 
  604.      * If CODEC_FLAG_EMU_EDGE is not set in s->flags, the buffer must contain an 
  605.      * edge of the size returned by avcodec_get_edge_width() on all sides. 
  606.      * 
  607.      * avcodec_align_dimensions2() should be used to find the required width and 
  608.      * height, as they normally need to be rounded up to the next multiple of 16. 
  609.      * 
  610.      * If frame multithreading is used and thread_safe_callbacks is set, 
  611.      * this callback may be called from a different thread, but not from more 
  612.      * than one at once. Does not need to be reentrant. 
  613.      * 
  614.      * @see avcodec_align_dimensions2() 
  615.      * 
  616.      * Audio: 
  617.      * 
  618.      * Decoders request a buffer of a particular size by setting 
  619.      * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may, 
  620.      * however, utilize only part of the buffer by setting AVFrame.nb_samples 
  621.      * to a smaller value in the output frame. 
  622.      * 
  623.      * As a convenience, av_samples_get_buffer_size() and 
  624.      * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2() 
  625.      * functions to find the required data size and to fill data pointers and 
  626.      * linesize. In AVFrame.linesize, only linesize[0] may be set for audio 
  627.      * since all planes must be the same size. 
  628.      * 
  629.      * @see av_samples_get_buffer_size(), av_samples_fill_arrays() 
  630.      * 
  631.      * - encoding: unused 
  632.      * - decoding: Set by libavcodec, user can override. 
  633.      */  
  634.     int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);  
  635.   
  636.     /** 
  637.      * If non-zero, the decoded audio and video frames returned from 
  638.      * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted 
  639.      * and are valid indefinitely. The caller must free them with 
  640.      * av_frame_unref() when they are not needed anymore. 
  641.      * Otherwise, the decoded frames must not be freed by the caller and are 
  642.      * only valid until the next decode call. 
  643.      * 
  644.      * - encoding: unused 
  645.      * - decoding: set by the caller before avcodec_open2(). 
  646.      */  
  647.     int refcounted_frames;  
  648.   
  649.     /* - encoding parameters */  
  650.     float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)  
  651.     float qblur;      ///< amount of qscale smoothing over time (0.0-1.0)  
  652.   
  653.     /** 
  654.      * minimum quantizer 
  655.      * - encoding: Set by user. 
  656.      * - decoding: unused 
  657.      */  
  658.     int qmin;  
  659.   
  660.     /** 
  661.      * maximum quantizer 
  662.      * - encoding: Set by user. 
  663.      * - decoding: unused 
  664.      */  
  665.     int qmax;  
  666.   
  667.     /** 
  668.      * maximum quantizer difference between frames 
  669.      * - encoding: Set by user. 
  670.      * - decoding: unused 
  671.      */  
  672.     int max_qdiff;  
  673.   
  674.     /** 
  675.      * ratecontrol qmin qmax limiting method 
  676.      * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax. 
  677.      * - encoding: Set by user. 
  678.      * - decoding: unused 
  679.      */  
  680.     float rc_qsquish;  
  681.   
  682.     float rc_qmod_amp;  
  683.     int rc_qmod_freq;  
  684.   
  685.     /** 
  686.      * decoder bitstream buffer size 
  687.      * - encoding: Set by user. 
  688.      * - decoding: unused 
  689.      */  
  690.     int rc_buffer_size;  
  691.   
  692.     /** 
  693.      * ratecontrol override, see RcOverride 
  694.      * - encoding: Allocated/set/freed by user. 
  695.      * - decoding: unused 
  696.      */  
  697.     int rc_override_count;  
  698.     RcOverride *rc_override;  
  699.   
  700.     /** 
  701.      * rate control equation 
  702.      * - encoding: Set by user 
  703.      * - decoding: unused 
  704.      */  
  705.     const char *rc_eq;  
  706.   
  707.     /** 
  708.      * maximum bitrate 
  709.      * - encoding: Set by user. 
  710.      * - decoding: unused 
  711.      */  
  712.     int rc_max_rate;  
  713.   
  714.     /** 
  715.      * minimum bitrate 
  716.      * - encoding: Set by user. 
  717.      * - decoding: unused 
  718.      */  
  719.     int rc_min_rate;  
  720.   
  721.     float rc_buffer_aggressivity;  
  722.   
  723.     /** 
  724.      * initial complexity for pass1 ratecontrol 
  725.      * - encoding: Set by user. 
  726.      * - decoding: unused 
  727.      */  
  728.     float rc_initial_cplx;  
  729.   
  730.     /** 
  731.      * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow. 
  732.      * - encoding: Set by user. 
  733.      * - decoding: unused. 
  734.      */  
  735.     float rc_max_available_vbv_use;  
  736.   
  737.     /** 
  738.      * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow. 
  739.      * - encoding: Set by user. 
  740.      * - decoding: unused. 
  741.      */  
  742.     float rc_min_vbv_overflow_use;  
  743.   
  744.     /** 
  745.      * Number of bits which should be loaded into the rc buffer before decoding starts. 
  746.      * - encoding: Set by user. 
  747.      * - decoding: unused 
  748.      */  
  749.     int rc_initial_buffer_occupancy;  
  750.   
  751. #define FF_CODER_TYPE_VLC       0  
  752. #define FF_CODER_TYPE_AC        1  
  753. #define FF_CODER_TYPE_RAW       2  
  754. #define FF_CODER_TYPE_RLE       3  
  755. #define FF_CODER_TYPE_DEFLATE   4  
  756.     /** 
  757.      * coder type 
  758.      * - encoding: Set by user. 
  759.      * - decoding: unused 
  760.      */  
  761.     int coder_type;  
  762.   
  763.     /** 
  764.      * context model 
  765.      * - encoding: Set by user. 
  766.      * - decoding: unused 
  767.      */  
  768.     int context_model;  
  769.   
  770.     /** 
  771.      * minimum Lagrange multipler 
  772.      * - encoding: Set by user. 
  773.      * - decoding: unused 
  774.      */  
  775.     int lmin;  
  776.   
  777.     /** 
  778.      * maximum Lagrange multipler 
  779.      * - encoding: Set by user. 
  780.      * - decoding: unused 
  781.      */  
  782.     int lmax;  
  783.   
  784.     /** 
  785.      * frame skip threshold 
  786.      * - encoding: Set by user. 
  787.      * - decoding: unused 
  788.      */  
  789.     int frame_skip_threshold;  
  790.   
  791.     /** 
  792.      * frame skip factor 
  793.      * - encoding: Set by user. 
  794.      * - decoding: unused 
  795.      */  
  796.     int frame_skip_factor;  
  797.   
  798.     /** 
  799.      * frame skip exponent 
  800.      * - encoding: Set by user. 
  801.      * - decoding: unused 
  802.      */  
  803.     int frame_skip_exp;  
  804.   
  805.     /** 
  806.      * frame skip comparison function 
  807.      * - encoding: Set by user. 
  808.      * - decoding: unused 
  809.      */  
  810.     int frame_skip_cmp;  
  811.   
  812.     /** 
  813.      * trellis RD quantization 
  814.      * - encoding: Set by user. 
  815.      * - decoding: unused 
  816.      */  
  817.     int trellis;  
  818.   
  819.     /** 
  820.      * - encoding: Set by user. 
  821.      * - decoding: unused 
  822.      */  
  823.     int min_prediction_order;  
  824.   
  825.     /** 
  826.      * - encoding: Set by user. 
  827.      * - decoding: unused 
  828.      */  
  829.     int max_prediction_order;  
  830.   
  831.     /** 
  832.      * GOP timecode frame start number 
  833.      * - encoding: Set by user, in non drop frame format 
  834.      * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset) 
  835.      */  
  836.     int64_t timecode_frame_start;  
  837.   
  838.     /* The RTP callback: This function is called    */  
  839.     /* every time the encoder has a packet to send. */  
  840.     /* It depends on the encoder if the data starts */  
  841.     /* with a Start Code (it should). H.263 does.   */  
  842.     /* mb_nb contains the number of macroblocks     */  
  843.     /* encoded in the RTP payload.                  */  
  844.     void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);  
  845.   
  846.     int rtp_payload_size;   /* The size of the RTP payload: the coder will  */  
  847.                             /* do its best to deliver a chunk with size     */  
  848.                             /* below rtp_payload_size, the chunk will start */  
  849.                             /* with a start code on some codecs like H.263. */  
  850.                             /* This doesn't take account of any particular  */  
  851.                             /* headers inside the transmitted RTP payload.  */  
  852.   
  853.     /* statistics, used for 2-pass encoding */  
  854.     int mv_bits;  
  855.     int header_bits;  
  856.     int i_tex_bits;  
  857.     int p_tex_bits;  
  858.     int i_count;  
  859.     int p_count;  
  860.     int skip_count;  
  861.     int misc_bits;  
  862.   
  863.     /** 
  864.      * number of bits used for the previously encoded frame 
  865.      * - encoding: Set by libavcodec. 
  866.      * - decoding: unused 
  867.      */  
  868.     int frame_bits;  
  869.   
  870.     /** 
  871.      * pass1 encoding statistics output buffer 
  872.      * - encoding: Set by libavcodec. 
  873.      * - decoding: unused 
  874.      */  
  875.     char *stats_out;  
  876.   
  877.     /** 
  878.      * pass2 encoding statistics input buffer 
  879.      * Concatenated stuff from stats_out of pass1 should be placed here. 
  880.      * - encoding: Allocated/set/freed by user. 
  881.      * - decoding: unused 
  882.      */  
  883.     char *stats_in;  
  884.   
  885.     /** 
  886.      * Work around bugs in encoders which sometimes cannot be detected automatically. 
  887.      * - encoding: Set by user 
  888.      * - decoding: Set by user 
  889.      */  
  890.     int workaround_bugs;  
  891. #define FF_BUG_AUTODETECT       1  ///< autodetection  
  892. #define FF_BUG_OLD_MSMPEG4      2  
  893. #define FF_BUG_XVID_ILACE       4  
  894. #define FF_BUG_UMP4             8  
  895. #define FF_BUG_NO_PADDING       16  
  896. #define FF_BUG_AMV              32  
  897. #define FF_BUG_AC_VLC           0  ///< Will be removed, libavcodec can now handle these non-compliant files by default.  
  898. #define FF_BUG_QPEL_CHROMA      64  
  899. #define FF_BUG_STD_QPEL         128  
  900. #define FF_BUG_QPEL_CHROMA2     256  
  901. #define FF_BUG_DIRECT_BLOCKSIZE 512  
  902. #define FF_BUG_EDGE             1024  
  903. #define FF_BUG_HPEL_CHROMA      2048  
  904. #define FF_BUG_DC_CLIP          4096  
  905. #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders.  
  906. #define FF_BUG_TRUNCATED       16384  
  907.   
  908.     /** 
  909.      * strictly follow the standard (MPEG4, ...). 
  910.      * - encoding: Set by user. 
  911.      * - decoding: Set by user. 
  912.      * Setting this to STRICT or higher means the encoder and decoder will 
  913.      * generally do stupid things, whereas setting it to unofficial or lower 
  914.      * will mean the encoder might produce output that is not supported by all 
  915.      * spec-compliant decoders. Decoders don't differentiate between normal, 
  916.      * unofficial and experimental (that is, they always try to decode things 
  917.      * when they can) unless they are explicitly asked to behave stupidly 
  918.      * (=strictly conform to the specs) 
  919.      */  
  920.     int strict_std_compliance;  
  921. #define FF_COMPLIANCE_VERY_STRICT   2 ///< Strictly conform to an older more strict version of the spec or reference software.  
  922. #define FF_COMPLIANCE_STRICT        1 ///< Strictly conform to all the things in the spec no matter what consequences.  
  923. #define FF_COMPLIANCE_NORMAL        0  
  924. #define FF_COMPLIANCE_UNOFFICIAL   -1 ///< Allow unofficial extensions  
  925. #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.  
  926.   
  927.     /** 
  928.      * error concealment flags 
  929.      * - encoding: unused 
  930.      * - decoding: Set by user. 
  931.      */  
  932.     int error_concealment;  
  933. #define FF_EC_GUESS_MVS   1  
  934. #define FF_EC_DEBLOCK     2  
  935.   
  936.     /** 
  937.      * debug 
  938.      * - encoding: Set by user. 
  939.      * - decoding: Set by user. 
  940.      */  
  941.     int debug;  
  942. #define FF_DEBUG_PICT_INFO   1  
  943. #define FF_DEBUG_RC          2  
  944. #define FF_DEBUG_BITSTREAM   4  
  945. #define FF_DEBUG_MB_TYPE     8  
  946. #define FF_DEBUG_QP          16  
  947. #define FF_DEBUG_MV          32  
  948. #define FF_DEBUG_DCT_COEFF   0x00000040  
  949. #define FF_DEBUG_SKIP        0x00000080  
  950. #define FF_DEBUG_STARTCODE   0x00000100  
  951. #define FF_DEBUG_PTS         0x00000200  
  952. #define FF_DEBUG_ER          0x00000400  
  953. #define FF_DEBUG_MMCO        0x00000800  
  954. #define FF_DEBUG_BUGS        0x00001000  
  955. #define FF_DEBUG_VIS_QP      0x00002000  
  956. #define FF_DEBUG_VIS_MB_TYPE 0x00004000  
  957. #define FF_DEBUG_BUFFERS     0x00008000  
  958. #define FF_DEBUG_THREADS     0x00010000  
  959.   
  960.     /** 
  961.      * debug 
  962.      * - encoding: Set by user. 
  963.      * - decoding: Set by user. 
  964.      */  
  965.     int debug_mv;  
  966. #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 //visualize forward predicted MVs of P frames  
  967. #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames  
  968. #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames  
  969.   
  970.     /** 
  971.      * Error recognition; may misdetect some more or less valid parts as errors. 
  972.      * - encoding: unused 
  973.      * - decoding: Set by user. 
  974.      */  
  975.     int err_recognition;  
  976. #define AV_EF_CRCCHECK  (1<<0)          ///< verify embedded CRCs  
  977. #define AV_EF_BITSTREAM (1<<1)          ///< detect bitstream specification deviations  
  978. #define AV_EF_BUFFER    (1<<2)          ///< detect improper bitstream length  
  979. #define AV_EF_EXPLODE   (1<<3)          ///< abort decoding on minor error detection  
  980.   
  981. #define AV_EF_CAREFUL    (1<<16)        ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors  
  982. #define AV_EF_COMPLIANT  (1<<17)        ///< consider all spec non compliancies as errors  
  983. #define AV_EF_AGGRESSIVE (1<<18)        ///< consider things that a sane encoder should not do as an error  
  984.   
  985.   
  986.     /** 
  987.      * opaque 64bit number (generally a PTS) that will be reordered and 
  988.      * output in AVFrame.reordered_opaque 
  989.      * @deprecated in favor of pkt_pts 
  990.      * - encoding: unused 
  991.      * - decoding: Set by user. 
  992.      */  
  993.     int64_t reordered_opaque;  
  994.   
  995.     /** 
  996.      * Hardware accelerator in use 
  997.      * - encoding: unused. 
  998.      * - decoding: Set by libavcodec 
  999.      */  
  1000.     struct AVHWAccel *hwaccel;  
  1001.   
  1002.     /** 
  1003.      * Hardware accelerator context. 
  1004.      * For some hardware accelerators, a global context needs to be 
  1005.      * provided by the user. In that case, this holds display-dependent 
  1006.      * data FFmpeg cannot instantiate itself. Please refer to the 
  1007.      * FFmpeg HW accelerator documentation to know how to fill this 
  1008.      * is. e.g. for VA API, this is a struct vaapi_context. 
  1009.      * - encoding: unused 
  1010.      * - decoding: Set by user 
  1011.      */  
  1012.     void *hwaccel_context;  
  1013.   
  1014.     /** 
  1015.      * error 
  1016.      * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. 
  1017.      * - decoding: unused 
  1018.      */  
  1019.     uint64_t error[AV_NUM_DATA_POINTERS];  
  1020.   
  1021.     /** 
  1022.      * DCT algorithm, see FF_DCT_* below 
  1023.      * - encoding: Set by user. 
  1024.      * - decoding: unused 
  1025.      */  
  1026.     int dct_algo;  
  1027. #define FF_DCT_AUTO    0  
  1028. #define FF_DCT_FASTINT 1  
  1029. #define FF_DCT_INT     2  
  1030. #define FF_DCT_MMX     3  
  1031. #define FF_DCT_ALTIVEC 5  
  1032. #define FF_DCT_FAAN    6  
  1033.   
  1034.     /** 
  1035.      * IDCT algorithm, see FF_IDCT_* below. 
  1036.      * - encoding: Set by user. 
  1037.      * - decoding: Set by user. 
  1038.      */  
  1039.     int idct_algo;  
  1040. #define FF_IDCT_AUTO          0  
  1041. #define FF_IDCT_INT           1  
  1042. #define FF_IDCT_SIMPLE        2  
  1043. #define FF_IDCT_SIMPLEMMX     3  
  1044. #define FF_IDCT_ARM           7  
  1045. #define FF_IDCT_ALTIVEC       8  
  1046. #define FF_IDCT_SH4           9  
  1047. #define FF_IDCT_SIMPLEARM     10  
  1048. #define FF_IDCT_IPP           13  
  1049. #define FF_IDCT_XVIDMMX       14  
  1050. #define FF_IDCT_SIMPLEARMV5TE 16  
  1051. #define FF_IDCT_SIMPLEARMV6   17  
  1052. #define FF_IDCT_SIMPLEVIS     18  
  1053. #define FF_IDCT_FAAN          20  
  1054. #define FF_IDCT_SIMPLENEON    22  
  1055. #define FF_IDCT_SIMPLEALPHA   23  
  1056.   
  1057.     /** 
  1058.      * bits per sample/pixel from the demuxer (needed for huffyuv). 
  1059.      * - encoding: Set by libavcodec. 
  1060.      * - decoding: Set by user. 
  1061.      */  
  1062.      int bits_per_coded_sample;  
  1063.   
  1064.     /** 
  1065.      * Bits per sample/pixel of internal libavcodec pixel/sample format. 
  1066.      * - encoding: set by user. 
  1067.      * - decoding: set by libavcodec. 
  1068.      */  
  1069.     int bits_per_raw_sample;  
  1070.   
  1071. #if FF_API_LOWRES  
  1072.     /** 
  1073.      * low resolution decoding, 1-> 1/2 size, 2->1/4 size 
  1074.      * - encoding: unused 
  1075.      * - decoding: Set by user. 
  1076.      * Code outside libavcodec should access this field using: 
  1077.      * av_codec_{get,set}_lowres(avctx) 
  1078.      */  
  1079.      int lowres;  
  1080. #endif  
  1081.   
  1082.     /** 
  1083.      * the picture in the bitstream 
  1084.      * - encoding: Set by libavcodec. 
  1085.      * - decoding: Set by libavcodec. 
  1086.      */  
  1087.     AVFrame *coded_frame;  
  1088.   
  1089.     /** 
  1090.      * thread count 
  1091.      * is used to decide how many independent tasks should be passed to execute() 
  1092.      * - encoding: Set by user. 
  1093.      * - decoding: Set by user. 
  1094.      */  
  1095.     int thread_count;  
  1096.   
  1097.     /** 
  1098.      * Which multithreading methods to use. 
  1099.      * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, 
  1100.      * so clients which cannot provide future frames should not use it. 
  1101.      * 
  1102.      * - encoding: Set by user, otherwise the default is used. 
  1103.      * - decoding: Set by user, otherwise the default is used. 
  1104.      */  
  1105.     int thread_type;  
  1106. #define FF_THREAD_FRAME   1 ///< Decode more than one frame at once  
  1107. #define FF_THREAD_SLICE   2 ///< Decode more than one part of a single frame at once  
  1108.   
  1109.     /** 
  1110.      * Which multithreading methods are in use by the codec. 
  1111.      * - encoding: Set by libavcodec. 
  1112.      * - decoding: Set by libavcodec. 
  1113.      */  
  1114.     int active_thread_type;  
  1115.   
  1116.     /** 
  1117.      * Set by the client if its custom get_buffer() callback can be called 
  1118.      * synchronously from another thread, which allows faster multithreaded decoding. 
  1119.      * draw_horiz_band() will be called from other threads regardless of this setting. 
  1120.      * Ignored if the default get_buffer() is used. 
  1121.      * - encoding: Set by user. 
  1122.      * - decoding: Set by user. 
  1123.      */  
  1124.     int thread_safe_callbacks;  
  1125.   
  1126.     /** 
  1127.      * The codec may call this to execute several independent things. 
  1128.      * It will return only after finishing all tasks. 
  1129.      * The user may replace this with some multithreaded implementation, 
  1130.      * the default implementation will execute the parts serially. 
  1131.      * @param count the number of things to execute 
  1132.      * - encoding: Set by libavcodec, user can override. 
  1133.      * - decoding: Set by libavcodec, user can override. 
  1134.      */  
  1135.     int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);  
  1136.   
  1137.     /** 
  1138.      * The codec may call this to execute several independent things. 
  1139.      * It will return only after finishing all tasks. 
  1140.      * The user may replace this with some multithreaded implementation, 
  1141.      * the default implementation will execute the parts serially. 
  1142.      * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. 
  1143.      * @param c context passed also to func 
  1144.      * @param count the number of things to execute 
  1145.      * @param arg2 argument passed unchanged to func 
  1146.      * @param ret return values of executed functions, must have space for "count" values. May be NULL. 
  1147.      * @param func function that will be called count times, with jobnr from 0 to count-1. 
  1148.      *             threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no 
  1149.      *             two instances of func executing at the same time will have the same threadnr. 
  1150.      * @return always 0 currently, but code should handle a future improvement where when any call to func 
  1151.      *         returns < 0 no further calls to func may be done and < 0 is returned. 
  1152.      * - encoding: Set by libavcodec, user can override. 
  1153.      * - decoding: Set by libavcodec, user can override. 
  1154.      */  
  1155.     int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);  
  1156.   
  1157.     /** 
  1158.      * thread opaque 
  1159.      * Can be used by execute() to store some per AVCodecContext stuff. 
  1160.      * - encoding: set by execute() 
  1161.      * - decoding: set by execute() 
  1162.      */  
  1163.     void *thread_opaque;  
  1164.   
  1165.     /** 
  1166.      * noise vs. sse weight for the nsse comparsion function 
  1167.      * - encoding: Set by user. 
  1168.      * - decoding: unused 
  1169.      */  
  1170.      int nsse_weight;  
  1171.   
  1172.     /** 
  1173.      * profile 
  1174.      * - encoding: Set by user. 
  1175.      * - decoding: Set by libavcodec. 
  1176.      */  
  1177.      int profile;  
  1178. #define FF_PROFILE_UNKNOWN -99  
  1179. #define FF_PROFILE_RESERVED -100  
  1180.   
  1181. #define FF_PROFILE_AAC_MAIN 0  
  1182. #define FF_PROFILE_AAC_LOW  1  
  1183. #define FF_PROFILE_AAC_SSR  2  
  1184. #define FF_PROFILE_AAC_LTP  3  
  1185. #define FF_PROFILE_AAC_HE   4  
  1186. #define FF_PROFILE_AAC_HE_V2 28  
  1187. #define FF_PROFILE_AAC_LD   22  
  1188. #define FF_PROFILE_AAC_ELD  38  
  1189. #define FF_PROFILE_MPEG2_AAC_LOW 128  
  1190. #define FF_PROFILE_MPEG2_AAC_HE  131  
  1191.   
  1192. #define FF_PROFILE_DTS         20  
  1193. #define FF_PROFILE_DTS_ES      30  
  1194. #define FF_PROFILE_DTS_96_24   40  
  1195. #define FF_PROFILE_DTS_HD_HRA  50  
  1196. #define FF_PROFILE_DTS_HD_MA   60  
  1197.   
  1198. #define FF_PROFILE_MPEG2_422    0  
  1199. #define FF_PROFILE_MPEG2_HIGH   1  
  1200. #define FF_PROFILE_MPEG2_SS     2  
  1201. #define FF_PROFILE_MPEG2_SNR_SCALABLE  3  
  1202. #define FF_PROFILE_MPEG2_MAIN   4  
  1203. #define FF_PROFILE_MPEG2_SIMPLE 5  
  1204.   
  1205. #define FF_PROFILE_H264_CONSTRAINED  (1<<9)  // 8+1; constraint_set1_flag  
  1206. #define FF_PROFILE_H264_INTRA        (1<<11) // 8+3; constraint_set3_flag  
  1207.   
  1208. #define FF_PROFILE_H264_BASELINE             66  
  1209. #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)  
  1210. #define FF_PROFILE_H264_MAIN                 77  
  1211. #define FF_PROFILE_H264_EXTENDED             88  
  1212. #define FF_PROFILE_H264_HIGH                 100  
  1213. #define FF_PROFILE_H264_HIGH_10              110  
  1214. #define FF_PROFILE_H264_HIGH_10_INTRA        (110|FF_PROFILE_H264_INTRA)  
  1215. #define FF_PROFILE_H264_HIGH_422             122  
  1216. #define FF_PROFILE_H264_HIGH_422_INTRA       (122|FF_PROFILE_H264_INTRA)  
  1217. #define FF_PROFILE_H264_HIGH_444             144  
  1218. #define FF_PROFILE_H264_HIGH_444_PREDICTIVE  244  
  1219. #define FF_PROFILE_H264_HIGH_444_INTRA       (244|FF_PROFILE_H264_INTRA)  
  1220. #define FF_PROFILE_H264_CAVLC_444            44  
  1221.   
  1222. #define FF_PROFILE_VC1_SIMPLE   0  
  1223. #define FF_PROFILE_VC1_MAIN     1  
  1224. #define FF_PROFILE_VC1_COMPLEX  2  
  1225. #define FF_PROFILE_VC1_ADVANCED 3  
  1226.   
  1227. #define FF_PROFILE_MPEG4_SIMPLE                     0  
  1228. #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE            1  
  1229. #define FF_PROFILE_MPEG4_CORE                       2  
  1230. #define FF_PROFILE_MPEG4_MAIN                       3  
  1231. #define FF_PROFILE_MPEG4_N_BIT                      4  
  1232. #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE           5  
  1233. #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION      6  
  1234. #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE     7  
  1235. #define FF_PROFILE_MPEG4_HYBRID                     8  
  1236. #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME         9  
  1237. #define FF_PROFILE_MPEG4_CORE_SCALABLE             10  
  1238. #define FF_PROFILE_MPEG4_ADVANCED_CODING           11  
  1239. #define FF_PROFILE_MPEG4_ADVANCED_CORE             12  
  1240. #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13  
  1241. #define FF_PROFILE_MPEG4_SIMPLE_STUDIO             14  
  1242. #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE           15  
  1243.   
  1244. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0   0  
  1245. #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1   1  
  1246. #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION  2  
  1247. #define FF_PROFILE_JPEG2000_DCINEMA_2K              3  
  1248. #define FF_PROFILE_JPEG2000_DCINEMA_4K              4  
  1249.   
  1250.     /** 
  1251.      * level 
  1252.      * - encoding: Set by user. 
  1253.      * - decoding: Set by libavcodec. 
  1254.      */  
  1255.      int level;  
  1256. #define FF_LEVEL_UNKNOWN -99  
  1257.   
  1258.     /** 
  1259.      * Skip loop filtering for selected frames. 
  1260.      * - encoding: unused 
  1261.      * - decoding: Set by user. 
  1262.      */  
  1263.     enum AVDiscard skip_loop_filter;  
  1264.   
  1265.     /** 
  1266.      * Skip IDCT/dequantization for selected frames. 
  1267.      * - encoding: unused 
  1268.      * - decoding: Set by user. 
  1269.      */  
  1270.     enum AVDiscard skip_idct;  
  1271.   
  1272.     /** 
  1273.      * Skip decoding for selected frames. 
  1274.      * - encoding: unused 
  1275.      * - decoding: Set by user. 
  1276.      */  
  1277.     enum AVDiscard skip_frame;  
  1278.   
  1279.     /** 
  1280.      * Header containing style information for text subtitles. 
  1281.      * For SUBTITLE_ASS subtitle type, it should contain the whole ASS 
  1282.      * [Script Info] and [V4+ Styles] section, plus the [Events] line and 
  1283.      * the Format line following. It shouldn't include any Dialogue line. 
  1284.      * - encoding: Set/allocated/freed by user (before avcodec_open2()) 
  1285.      * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) 
  1286.      */  
  1287.     uint8_t *subtitle_header;  
  1288.     int subtitle_header_size;  
  1289.   
  1290.     /** 
  1291.      * Simulates errors in the bitstream to test error concealment. 
  1292.      * - encoding: Set by user. 
  1293.      * - decoding: unused 
  1294.      */  
  1295.     int error_rate;  
  1296.   
  1297.     /** 
  1298.      * Current packet as passed into the decoder, to avoid having 
  1299.      * to pass the packet into every function. Currently only valid 
  1300.      * inside lavc and get/release_buffer callbacks. 
  1301.      * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts 
  1302.      * - encoding: unused 
  1303.      */  
  1304.     AVPacket *pkt;  
  1305.   
  1306.     /** 
  1307.      * VBV delay coded in the last frame (in periods of a 27 MHz clock). 
  1308.      * Used for compliant TS muxing. 
  1309.      * - encoding: Set by libavcodec. 
  1310.      * - decoding: unused. 
  1311.      */  
  1312.     uint64_t vbv_delay;  
  1313.   
  1314.     /** 
  1315.      * Timebase in which pkt_dts/pts and AVPacket.dts/pts are. 
  1316.      * Code outside libavcodec should access this field using: 
  1317.      * av_codec_{get,set}_pkt_timebase(avctx) 
  1318.      * - encoding unused. 
  1319.      * - decoding set by user. 
  1320.      */  
  1321.     AVRational pkt_timebase;  
  1322.   
  1323.     /** 
  1324.      * AVCodecDescriptor 
  1325.      * Code outside libavcodec should access this field using: 
  1326.      * av_codec_{get,set}_codec_descriptor(avctx) 
  1327.      * - encoding: unused. 
  1328.      * - decoding: set by libavcodec. 
  1329.      */  
  1330.     const AVCodecDescriptor *codec_descriptor;  
  1331.   
  1332. #if !FF_API_LOWRES  
  1333.     /** 
  1334.      * low resolution decoding, 1-> 1/2 size, 2->1/4 size 
  1335.      * - encoding: unused 
  1336.      * - decoding: Set by user. 
  1337.      * Code outside libavcodec should access this field using: 
  1338.      * av_codec_{get,set}_lowres(avctx) 
  1339.      */  
  1340.      int lowres;  
  1341. #endif  
  1342.   
  1343.     /** 
  1344.      * Current statistics for PTS correction. 
  1345.      * - decoding: maintained and used by libavcodec, not intended to be used by user apps 
  1346.      * - encoding: unused 
  1347.      */  
  1348.     int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far  
  1349.     int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far  
  1350.     int64_t pts_correction_last_pts;       /// PTS of the last frame  
  1351.     int64_t pts_correction_last_dts;       /// DTS of the last frame  
  1352.   
  1353.     /** 
  1354.      * Character encoding of the input subtitles file. 
  1355.      * - decoding: set by user 
  1356.      * - encoding: unused 
  1357.      */  
  1358.     char *sub_charenc;  
  1359.   
  1360.     /** 
  1361.      * Subtitles character encoding mode. Formats or codecs might be adjusting 
  1362.      * this setting (if they are doing the conversion themselves for instance). 
  1363.      * - decoding: set by libavcodec 
  1364.      * - encoding: unused 
  1365.      */  
  1366.     int sub_charenc_mode;  
  1367. #define FF_SUB_CHARENC_MODE_DO_NOTHING  -1  ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)  
  1368. #define FF_SUB_CHARENC_MODE_AUTOMATIC    0  ///< libavcodec will select the mode itself  
  1369. #define FF_SUB_CHARENC_MODE_PRE_DECODER  1  ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv  
  1370.   
  1371.     /** 
  1372.      * Skip processing alpha if supported by codec. 
  1373.      * Note that if the format uses pre-multiplied alpha (common with VP6, 
  1374.      * and recommended due to better video quality/compression) 
  1375.      * the image will look as if alpha-blended onto a black background. 
  1376.      * However for formats that do not use pre-multiplied alpha 
  1377.      * there might be serious artefacts (though e.g. libswscale currently 
  1378.      * assumes pre-multiplied alpha anyway). 
  1379.      * Code outside libavcodec should access this field using AVOptions 
  1380.      * 
  1381.      * - decoding: set by user 
  1382.      * - encoding: unused 
  1383.      */  
  1384.     int skip_alpha;  
  1385.   
  1386.     /** 
  1387.      * Number of samples to skip after a discontinuity 
  1388.      * - decoding: unused 
  1389.      * - encoding: set by libavcodec 
  1390.      */  
  1391.     int seek_preroll;  
  1392. } AVCodecContext;  
这个结构体的内容极其庞大繁杂,但是看过其成员后便明白,它保存了编码视频时所用到的各种参数,包括编码格式即所用的编码器、编码过程中的参数等。其中很多都是编码标准算法中的相应的设置,比如GOP的大小,参考帧的数目,运动搜索范围的选择等等。具体技术细节比较复杂,需要学习的还要参考相应的编解码标准。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值