Revision fe74099a

View differences:

ffplay.c
1795 1795
static int stream_component_open(VideoState *is, int stream_index)
1796 1796
{
1797 1797
    AVFormatContext *ic = is->ic;
1798
    AVCodecContext *enc;
1798
    AVCodecContext *avctx;
1799 1799
    AVCodec *codec;
1800 1800
    SDL_AudioSpec wanted_spec, spec;
1801 1801

  
1802 1802
    if (stream_index < 0 || stream_index >= ic->nb_streams)
1803 1803
        return -1;
1804
    enc = ic->streams[stream_index]->codec;
1804
    avctx = ic->streams[stream_index]->codec;
1805 1805

  
1806 1806
    /* prepare audio output */
1807
    if (enc->codec_type == CODEC_TYPE_AUDIO) {
1808
        if (enc->channels > 0) {
1809
            enc->request_channels = FFMIN(2, enc->channels);
1807
    if (avctx->codec_type == CODEC_TYPE_AUDIO) {
1808
        if (avctx->channels > 0) {
1809
            avctx->request_channels = FFMIN(2, avctx->channels);
1810 1810
        } else {
1811
            enc->request_channels = 2;
1811
            avctx->request_channels = 2;
1812 1812
        }
1813 1813
    }
1814 1814

  
1815
    codec = avcodec_find_decoder(enc->codec_id);
1816
    enc->debug_mv = debug_mv;
1817
    enc->debug = debug;
1818
    enc->workaround_bugs = workaround_bugs;
1819
    enc->lowres = lowres;
1820
    if(lowres) enc->flags |= CODEC_FLAG_EMU_EDGE;
1821
    enc->idct_algo= idct;
1822
    if(fast) enc->flags2 |= CODEC_FLAG2_FAST;
1823
    enc->skip_frame= skip_frame;
1824
    enc->skip_idct= skip_idct;
1825
    enc->skip_loop_filter= skip_loop_filter;
1826
    enc->error_recognition= error_recognition;
1827
    enc->error_concealment= error_concealment;
1828
    avcodec_thread_init(enc, thread_count);
1815
    codec = avcodec_find_decoder(avctx->codec_id);
1816
    avctx->debug_mv = debug_mv;
1817
    avctx->debug = debug;
1818
    avctx->workaround_bugs = workaround_bugs;
1819
    avctx->lowres = lowres;
1820
    if(lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
1821
    avctx->idct_algo= idct;
1822
    if(fast) avctx->flags2 |= CODEC_FLAG2_FAST;
1823
    avctx->skip_frame= skip_frame;
1824
    avctx->skip_idct= skip_idct;
1825
    avctx->skip_loop_filter= skip_loop_filter;
1826
    avctx->error_recognition= error_recognition;
1827
    avctx->error_concealment= error_concealment;
1828
    avcodec_thread_init(avctx, thread_count);
1829 1829

  
1830
    set_context_opts(enc, avcodec_opts[enc->codec_type], 0);
1830
    set_context_opts(avctx, avcodec_opts[avctx->codec_type], 0);
1831 1831

  
1832 1832
    if (!codec ||
1833
        avcodec_open(enc, codec) < 0)
1833
        avcodec_open(avctx, codec) < 0)
1834 1834
        return -1;
1835 1835

  
1836 1836
    /* prepare audio output */
1837
    if (enc->codec_type == CODEC_TYPE_AUDIO) {
1838
        wanted_spec.freq = enc->sample_rate;
1837
    if (avctx->codec_type == CODEC_TYPE_AUDIO) {
1838
        wanted_spec.freq = avctx->sample_rate;
1839 1839
        wanted_spec.format = AUDIO_S16SYS;
1840
        wanted_spec.channels = enc->channels;
1840
        wanted_spec.channels = avctx->channels;
1841 1841
        wanted_spec.silence = 0;
1842 1842
        wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
1843 1843
        wanted_spec.callback = sdl_audio_callback;
......
1851 1851
    }
1852 1852

  
1853 1853
    ic->streams[stream_index]->discard = AVDISCARD_DEFAULT;
1854
    switch(enc->codec_type) {
1854
    switch(avctx->codec_type) {
1855 1855
    case CODEC_TYPE_AUDIO:
1856 1856
        is->audio_stream = stream_index;
1857 1857
        is->audio_st = ic->streams[stream_index];
......
1863 1863
        is->audio_diff_avg_count = 0;
1864 1864
        /* since we do not have a precise anough audio fifo fullness,
1865 1865
           we correct audio sync only if larger than this threshold */
1866
        is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / enc->sample_rate;
1866
        is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / avctx->sample_rate;
1867 1867

  
1868 1868
        memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
1869 1869
        packet_queue_init(&is->audioq);
......
1894 1894
static void stream_component_close(VideoState *is, int stream_index)
1895 1895
{
1896 1896
    AVFormatContext *ic = is->ic;
1897
    AVCodecContext *enc;
1897
    AVCodecContext *avctx;
1898 1898

  
1899 1899
    if (stream_index < 0 || stream_index >= ic->nb_streams)
1900 1900
        return;
1901
    enc = ic->streams[stream_index]->codec;
1901
    avctx = ic->streams[stream_index]->codec;
1902 1902

  
1903
    switch(enc->codec_type) {
1903
    switch(avctx->codec_type) {
1904 1904
    case CODEC_TYPE_AUDIO:
1905 1905
        packet_queue_abort(&is->audioq);
1906 1906

  
......
1943 1943
    }
1944 1944

  
1945 1945
    ic->streams[stream_index]->discard = AVDISCARD_ALL;
1946
    avcodec_close(enc);
1947
    switch(enc->codec_type) {
1946
    avcodec_close(avctx);
1947
    switch(avctx->codec_type) {
1948 1948
    case CODEC_TYPE_AUDIO:
1949 1949
        is->audio_st = NULL;
1950 1950
        is->audio_stream = -1;
......
2042 2042
    }
2043 2043

  
2044 2044
    for(i = 0; i < ic->nb_streams; i++) {
2045
        AVCodecContext *enc = ic->streams[i]->codec;
2045
        AVCodecContext *avctx = ic->streams[i]->codec;
2046 2046
        ic->streams[i]->discard = AVDISCARD_ALL;
2047
        switch(enc->codec_type) {
2047
        switch(avctx->codec_type) {
2048 2048
        case CODEC_TYPE_AUDIO:
2049 2049
            if (wanted_audio_stream-- >= 0 && !audio_disable)
2050 2050
                audio_index = i;

Also available in: Unified diff