Browse code

avplay: convert do codecpar

Anton Khirnov authored on 2016/02/09 22:23:30
Showing 1 changed files
... ...
@@ -2017,11 +2017,11 @@ static AVCodec *choose_decoder(PlayerState *is, AVFormatContext *ic, AVStream *s
2017 2017
     }
2018 2018
 
2019 2019
     if (codec_name) {
2020
-        AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type);
2021
-        st->codec->codec_id = codec->id;
2020
+        AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type);
2021
+        st->codecpar->codec_id = codec->id;
2022 2022
         return codec;
2023 2023
     } else
2024
-        return avcodec_find_decoder(st->codec->codec_id);
2024
+        return avcodec_find_decoder(st->codecpar->codec_id);
2025 2025
 }
2026 2026
 
2027 2027
 /* open a given stream. Return 0 if OK */
... ...
@@ -2042,7 +2042,7 @@ static int stream_component_open(PlayerState *is, int stream_index)
2042 2042
     if (!avctx)
2043 2043
         return AVERROR(ENOMEM);
2044 2044
 
2045
-    ret = avcodec_copy_context(avctx, ic->streams[stream_index]->codec);
2045
+    ret = avcodec_parameters_to_context(avctx, ic->streams[stream_index]->codecpar);
2046 2046
     if (ret < 0) {
2047 2047
         avcodec_free_context(&avctx);
2048 2048
         return ret;
... ...
@@ -2160,13 +2160,13 @@ fail:
2160 2160
 static void stream_component_close(PlayerState *is, int stream_index)
2161 2161
 {
2162 2162
     AVFormatContext *ic = is->ic;
2163
-    AVCodecContext *avctx;
2163
+    AVCodecParameters *par;
2164 2164
 
2165 2165
     if (stream_index < 0 || stream_index >= ic->nb_streams)
2166 2166
         return;
2167
-    avctx = ic->streams[stream_index]->codec;
2167
+    par = ic->streams[stream_index]->codecpar;
2168 2168
 
2169
-    switch (avctx->codec_type) {
2169
+    switch (par->codec_type) {
2170 2170
     case AVMEDIA_TYPE_AUDIO:
2171 2171
         packet_queue_abort(&is->audioq);
2172 2172
 
... ...
@@ -2220,7 +2220,7 @@ static void stream_component_close(PlayerState *is, int stream_index)
2220 2220
     }
2221 2221
 
2222 2222
     ic->streams[stream_index]->discard = AVDISCARD_ALL;
2223
-    switch (avctx->codec_type) {
2223
+    switch (par->codec_type) {
2224 2224
     case AVMEDIA_TYPE_AUDIO:
2225 2225
         avcodec_free_context(&is->audio_dec);
2226 2226
         is->audio_st = NULL;
... ...
@@ -2311,7 +2311,7 @@ static int stream_setup(PlayerState *is)
2311 2311
     orig_nb_streams = ic->nb_streams;
2312 2312
 
2313 2313
     for (i = 0; i < ic->nb_streams; i++)
2314
-        ic->streams[i]->codec->codec = choose_decoder(is, ic, ic->streams[i]);
2314
+        choose_decoder(is, ic, ic->streams[i]);
2315 2315
 
2316 2316
     err = avformat_find_stream_info(ic, opts);
2317 2317
 
... ...
@@ -2596,12 +2596,12 @@ static void stream_cycle_channel(PlayerState *is, int codec_type)
2596 2596
         if (stream_index == start_index)
2597 2597
             return;
2598 2598
         st = ic->streams[stream_index];
2599
-        if (st->codec->codec_type == codec_type) {
2599
+        if (st->codecpar->codec_type == codec_type) {
2600 2600
             /* check that parameters are OK */
2601 2601
             switch (codec_type) {
2602 2602
             case AVMEDIA_TYPE_AUDIO:
2603
-                if (st->codec->sample_rate != 0 &&
2604
-                    st->codec->channels != 0)
2603
+                if (st->codecpar->sample_rate != 0 &&
2604
+                    st->codecpar->channels != 0)
2605 2605
                     goto the_end;
2606 2606
                 break;
2607 2607
             case AVMEDIA_TYPE_VIDEO: