upgrade to ffmpeg 4.2, rework mask for speedup
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / ffmpeg.C
index 3bb9dd8018c9075810154bf112e3843e4677dcb9..47c603f2f72feedc8429243dd4c7dd06f9783ab0 100644 (file)
@@ -455,7 +455,7 @@ int FFStream::decode(AVFrame *frame)
                        AVPacket *pkt = ret > 0 ? (AVPacket*)ipkt : 0;
                        if( pkt ) {
                                if( pkt->stream_index != st->index ) continue;
-                               if( !pkt->data | !pkt->size ) continue;
+                               if( !pkt->data || !pkt->size ) continue;
                        }
                        if( (ret=avcodec_send_packet(avctx, pkt)) < 0 ) {
                                ff_err(ret, "FFStream::decode: avcodec_send_packet failed.\nfile:%s\n",
@@ -835,7 +835,8 @@ int FFAudioStream::decode_frame(AVFrame *frame)
        frame->best_effort_timestamp = AV_NOPTS_VALUE;
        int ret = avcodec_receive_frame(avctx, frame);
        if( ret < 0 ) {
-               if( first_frame || ret == AVERROR(EAGAIN) ) return 0;
+               if( first_frame ) return 0;
+               if( ret == AVERROR(EAGAIN) ) return 0;
                if( ret == AVERROR_EOF ) { st_eof(1); return 0; }
                ff_err(ret, "FFAudioStream::decode_frame: Could not read audio frame.\nfile:%s\n",
                                ffmpeg->fmt_ctx->url);
@@ -1135,7 +1136,7 @@ int FFVideoStream::decode_frame(AVFrame *frame)
        int first_frame = seeked;  seeked = 0;
        int ret = avcodec_receive_frame(avctx, frame);
        if( ret < 0 ) {
-               if( first_frame || ret == AVERROR(EAGAIN) ) return 0;
+               if( first_frame ) return 0;
                if( ret == AVERROR(EAGAIN) ) return 0;
                if( ret == AVERROR_EOF ) { st_eof(1); return 0; }
                ff_err(ret, "FFVideoStream::decode_frame: Could not read video frame.\nfile:%s\n,",
@@ -2487,7 +2488,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                        vid->height = asset->height;
                        vid->frame_rate = asset->frame_rate;
 
-                       AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
+                       AVPixelFormat pix_fmt = av_get_pix_fmt(asset->ff_pixel_format);
                        if( opt_hw_dev != 0 ) {
                                AVHWDeviceType hw_type = vid->encode_hw_activate(opt_hw_dev);
                                switch( hw_type ) {
@@ -2495,9 +2496,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                                        pix_fmt = AV_PIX_FMT_VAAPI;
                                        break;
                                case AV_HWDEVICE_TYPE_NONE:
-                               default:
-                                       pix_fmt = av_get_pix_fmt(asset->ff_pixel_format);
-                                       break;
+                               default: break;
                                }
                        }
                        if( pix_fmt == AV_PIX_FMT_NONE )