| 2014 | } |
| 2015 | |
| 2016 | static int try_decode_frame(AVStream *st, AVPacket *avpkt) |
| 2017 | { |
| 2018 | int16_t *samples; |
| 2019 | AVCodec *codec; |
| 2020 | int got_picture, data_size, ret=0; |
| 2021 | AVFrame picture; |
| 2022 | |
| 2023 | if(!st->codec->codec){ |
| 2024 | codec = avcodec_find_decoder(st->codec->codec_id); |
| 2025 | if (!codec) |
| 2026 | return -1; |
| 2027 | ret = avcodec_open(st->codec, codec); |
| 2028 | if (ret < 0) |
| 2029 | return ret; |
| 2030 | } |
| 2031 | |
| 2032 | if(!has_codec_parameters(st->codec)){ |
| 2033 | switch(st->codec->codec_type) { |
| 2034 | case AVMEDIA_TYPE_VIDEO: |
| 2035 | avcodec_get_frame_defaults(&picture); |
| 2036 | ret = avcodec_decode_video2(st->codec, &picture, |
| 2037 | &got_picture, avpkt); |
| 2038 | break; |
| 2039 | case AVMEDIA_TYPE_AUDIO: |
| 2040 | data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE); |
| 2041 | samples = av_malloc(data_size); |
| 2042 | if (!samples) |
| 2043 | goto fail; |
| 2044 | ret = avcodec_decode_audio3(st->codec, samples, |
| 2045 | &data_size, avpkt); |
| 2046 | av_free(samples); |
| 2047 | break; |
| 2048 | default: |
| 2049 | break; |
| 2050 | } |
| 2051 | } |
| 2052 | fail: |
| 2053 | return ret; |
| 2054 | } |
| 2055 | |
| 2056 | unsigned int ff_codec_get_tag(const AVCodecTag *tags, int id) |
| 2057 | { |
no test coverage detected