unnecessary brackets removed

- distinction ffmpeg versions
This commit is contained in:
Frankenstone
2021-05-17 22:28:02 +02:00
committed by Thilo Graf
parent 284ee4a6ed
commit 86b0246599
4 changed files with 19 additions and 19 deletions

View File

@@ -204,7 +204,7 @@ void CFfmpegDec::DeInit(void)
{ {
if(c) if(c)
{ {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 83, 100)) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 83, 100)
avcodec_close(c); avcodec_close(c);
#else #else
avcodec_free_context(&c); avcodec_free_context(&c);
@@ -213,7 +213,7 @@ void CFfmpegDec::DeInit(void)
} }
if (avioc) if (avioc)
{ {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 83, 100)) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 83, 100)
av_free(avioc); av_free(avioc);
#else #else
av_freep(&avioc->buffer); av_freep(&avioc->buffer);
@@ -240,7 +240,7 @@ CBaseDec::RetCode CFfmpegDec::Decoder(FILE *_in, int /*OutputFd*/, State* state,
Status=DATA_ERR; Status=DATA_ERR;
return Status; return Status;
} }
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
c = avc->streams[best_stream]->codec; c = avc->streams[best_stream]->codec;
#else #else
c = avcodec_alloc_context3(codec); c = avcodec_alloc_context3(codec);
@@ -484,7 +484,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover)
if (!is_stream) { if (!is_stream) {
GetMeta(avc->metadata); GetMeta(avc->metadata);
for(unsigned int i = 0; i < avc->nb_streams; i++) { for(unsigned int i = 0; i < avc->nb_streams; i++) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
if (avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) if (avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
#else #else
if (avc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) if (avc->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -505,7 +505,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover)
DeInit(); DeInit();
return false; return false;
} }
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
if (!codec) if (!codec)
codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id); codec = avcodec_find_decoder(avc->streams[best_stream]->codec->codec_id);
samplerate = avc->streams[best_stream]->codec->sample_rate; samplerate = avc->streams[best_stream]->codec->sample_rate;
@@ -535,7 +535,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover)
printf("CFfmpegDec: format %s (%s) duration %ld\n", avc->iformat->name, type_info.c_str(), total_time); printf("CFfmpegDec: format %s (%s) duration %ld\n", avc->iformat->name, type_info.c_str(), total_time);
for(unsigned int i = 0; i < avc->nb_streams; i++) { for(unsigned int i = 0; i < avc->nb_streams; i++) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
if (avc->streams[i]->codec->bit_rate > 0) if (avc->streams[i]->codec->bit_rate > 0)
bitrate += avc->streams[i]->codec->bit_rate; bitrate += avc->streams[i]->codec->bit_rate;
#else #else

View File

@@ -78,7 +78,7 @@ class CStreamRec : public CRecordInstance, OpenThreads::Thread
private: private:
AVFormatContext *ifcx; AVFormatContext *ifcx;
AVFormatContext *ofcx; AVFormatContext *ofcx;
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
AVBitStreamFilterContext *bsfc; AVBitStreamFilterContext *bsfc;
#else #else
AVBSFContext *bsfc; AVBSFContext *bsfc;
@@ -1998,7 +1998,7 @@ void CStreamRec::Close()
avformat_free_context(ofcx); avformat_free_context(ofcx);
} }
if (bsfc){ if (bsfc){
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
av_bitstream_filter_close(bsfc); av_bitstream_filter_close(bsfc);
#else #else
av_bsf_free(&bsfc); av_bsf_free(&bsfc);
@@ -2020,7 +2020,7 @@ void CStreamRec::FillMovieInfo(CZapitChannel * /*channel*/, APIDList & /*apid_li
for (unsigned i = 0; i < ofcx->nb_streams; i++) { for (unsigned i = 0; i < ofcx->nb_streams; i++) {
AVStream *st = ofcx->streams[i]; AVStream *st = ofcx->streams[i];
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
AVCodecContext * codec = st->codec; AVCodecContext * codec = st->codec;
#else #else
AVCodecParameters * codec = st->codecpar; AVCodecParameters * codec = st->codecpar;
@@ -2268,7 +2268,7 @@ bool CStreamRec::Open(CZapitChannel * channel)
stream_index = -1; stream_index = -1;
int stid = 0x200; int stid = 0x200;
for (unsigned i = 0; i < ifcx->nb_streams; i++) { for (unsigned i = 0; i < ifcx->nb_streams; i++) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
AVCodecContext * iccx = ifcx->streams[i]->codec; AVCodecContext * iccx = ifcx->streams[i]->codec;
AVStream *ost = avformat_new_stream(ofcx, iccx->codec); AVStream *ost = avformat_new_stream(ofcx, iccx->codec);
avcodec_copy_context(ost->codec, iccx); avcodec_copy_context(ost->codec, iccx);
@@ -2292,7 +2292,7 @@ bool CStreamRec::Open(CZapitChannel * channel)
av_dump_format(ofcx, 0, ofcx->url, 1); av_dump_format(ofcx, 0, ofcx->url, 1);
#endif #endif
av_log_set_level(AV_LOG_WARNING); av_log_set_level(AV_LOG_WARNING);
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
bsfc = av_bitstream_filter_init("h264_mp4toannexb"); bsfc = av_bitstream_filter_init("h264_mp4toannexb");
if (!bsfc) if (!bsfc)
printf("%s: av_bitstream_filter_init h264_mp4toannexb failed!\n", __FUNCTION__); printf("%s: av_bitstream_filter_init h264_mp4toannexb failed!\n", __FUNCTION__);
@@ -2328,14 +2328,14 @@ void CStreamRec::run()
break; break;
if (pkt.stream_index < 0) if (pkt.stream_index < 0)
continue; continue;
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec; AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec;
#else #else
AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar; AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar;
#endif #endif
if (bsfc && codec->codec_id == AV_CODEC_ID_H264) { if (bsfc && codec->codec_id == AV_CODEC_ID_H264) {
AVPacket newpkt = pkt; AVPacket newpkt = pkt;
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) { if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) {
av_packet_unref(&pkt); av_packet_unref(&pkt);
newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0);

View File

@@ -788,7 +788,7 @@ void CStreamStream::Close()
av_free(avio_ctx); av_free(avio_ctx);
if (bsfc){ if (bsfc){
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
av_bitstream_filter_close(bsfc); av_bitstream_filter_close(bsfc);
#else #else
av_bsf_free(&bsfc); av_bsf_free(&bsfc);
@@ -887,7 +887,7 @@ bool CStreamStream::Open()
av_dict_copy(&ofcx->metadata, ifcx->metadata, 0); av_dict_copy(&ofcx->metadata, ifcx->metadata, 0);
int stid = 0x200; int stid = 0x200;
for (unsigned i = 0; i < ifcx->nb_streams; i++) { for (unsigned i = 0; i < ifcx->nb_streams; i++) {
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
AVCodecContext * iccx = ifcx->streams[i]->codec; AVCodecContext * iccx = ifcx->streams[i]->codec;
AVStream *ost = avformat_new_stream(ofcx, iccx->codec); AVStream *ost = avformat_new_stream(ofcx, iccx->codec);
avcodec_copy_context(ost->codec, iccx); avcodec_copy_context(ost->codec, iccx);
@@ -907,7 +907,7 @@ bool CStreamStream::Open()
av_dump_format(ofcx, 0, ofcx->url, 1); av_dump_format(ofcx, 0, ofcx->url, 1);
#endif #endif
av_log_set_level(AV_LOG_WARNING); av_log_set_level(AV_LOG_WARNING);
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
bsfc = av_bitstream_filter_init("h264_mp4toannexb"); bsfc = av_bitstream_filter_init("h264_mp4toannexb");
if (!bsfc) if (!bsfc)
printf("%s: av_bitstream_filter_init h264_mp4toannexb failed!\n", __FUNCTION__); printf("%s: av_bitstream_filter_init h264_mp4toannexb failed!\n", __FUNCTION__);
@@ -964,14 +964,14 @@ void CStreamStream::run()
if (pkt.stream_index < 0) if (pkt.stream_index < 0)
continue; continue;
#if (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )) #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT( 57,25,101 )
AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec; AVCodecContext *codec = ifcx->streams[pkt.stream_index]->codec;
#else #else
AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar; AVCodecParameters *codec = ifcx->streams[pkt.stream_index]->codecpar;
#endif #endif
if (bsfc && codec->codec_id == AV_CODEC_ID_H264 ) { if (bsfc && codec->codec_id == AV_CODEC_ID_H264 ) {
AVPacket newpkt = pkt; AVPacket newpkt = pkt;
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) { if (av_bitstream_filter_filter(bsfc, codec, NULL, &newpkt.data, &newpkt.size, pkt.data, pkt.size, pkt.flags & AV_PKT_FLAG_KEY) >= 0) {
av_packet_unref(&pkt); av_packet_unref(&pkt);
newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0); newpkt.buf = av_buffer_create(newpkt.data, newpkt.size, av_buffer_default_free, NULL, 0);

View File

@@ -73,7 +73,7 @@ class CStreamStream : public CStreamInstance
private: private:
AVFormatContext *ifcx; AVFormatContext *ifcx;
AVFormatContext *ofcx; AVFormatContext *ofcx;
#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 57,48,100 )
AVBitStreamFilterContext *bsfc; AVBitStreamFilterContext *bsfc;
#else #else
AVBSFContext *bsfc; AVBSFContext *bsfc;