fix ffmpeg render options setup menus, tweak h264/h265 formats for cuda
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / ffmpeg.h
index 15659944c9b3ef57ae599e2eac3527099b438db0..100d80f556e48856f9c25d8ffa2f4632514ad517 100644 (file)
@@ -20,6 +20,7 @@
 #include "fileffmpeg.inc"
 #include "indexstate.inc"
 #include "mutex.h"
+#include "preferences.inc"
 #include "thread.h"
 #include "vframe.inc"
 
@@ -68,6 +69,7 @@ public:
        int initted() { return init; }
        void queue(int64_t pos);
        void dequeue();
+       void set_hw_frame(AVFrame *frame);
 };
 
 class FFStream {
@@ -82,7 +84,7 @@ public:
        virtual int encode_activate();
        virtual int decode_activate();
        virtual AVHWDeviceType decode_hw_activate();
-       virtual void decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
+       virtual int decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
        virtual int write_packet(FFPacket &pkt);
        int read_packet();
        int seek(int64_t no, double rate);
@@ -203,10 +205,14 @@ public:
 
 class FFVideoConvert {
 public:
+       Preferences *preferences;
        struct SwsContext *convert_ctx;
        AVFrame *sw_frame;
 
-       FFVideoConvert() { convert_ctx = 0; sw_frame = 0; }
+       FFVideoConvert(Preferences *preferences) {
+               this->preferences = preferences;
+               convert_ctx = 0; sw_frame = 0;
+       }
        ~FFVideoConvert() {
                if( convert_ctx ) sws_freeContext(convert_ctx);
                if( sw_frame ) av_frame_free(&sw_frame);
@@ -234,7 +240,9 @@ public:
        int is_video() { return 1; }
        int decode_frame(AVFrame *frame);
        AVHWDeviceType decode_hw_activate();
-       void decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
+       int decode_hw_format(AVCodec *decoder, AVHWDeviceType type);
+       AVHWDeviceType encode_hw_activate(const char *hw_dev);
+       int encode_hw_write(FFrame *picture);
        int encode_frame(AVFrame *frame);
        int create_filter(const char *filter_spec, AVCodecParameters *avpar);
        void load_markers();
@@ -254,6 +262,23 @@ public:
 
        int interlaced;
        int top_field_first;
+       int color_space, color_range;
+};
+
+class FFCodecRemap
+{
+public:
+       FFCodecRemap();
+       ~FFCodecRemap();
+       const char *old_codec, *new_codec;
+};
+
+class FFCodecRemaps : public ArrayList<FFCodecRemap>
+{
+public:
+       FFCodecRemaps() {}
+       int add(const char *val);
+       int update(AVCodecID &codec_id, AVCodec *&decoder);
 };
 
 class FFMPEG : public Thread {
@@ -285,6 +310,8 @@ public:
        static void load_audio_options(Asset *asset, EDL *edl);
        static void scan_video_options(Asset *asset, EDL *edl);
        static void load_video_options(Asset *asset, EDL *edl);
+       static void scan_format_options(Asset *asset, EDL *edl);
+       static void load_format_options(Asset *asset, EDL *edl);
        static void set_asset_format(Asset *asset, EDL *edl, const char *text);
        int get_file_format();
        static int get_encoder(const char *options, char *format, char *codec, char *bsfilter);
@@ -326,6 +353,10 @@ public:
        char *opt_video_filter;
        char *opt_audio_filter;
        char *opt_hw_dev;
+       char *opt_video_decoder;
+       char *opt_audio_decoder;
+       FFCodecRemaps video_codec_remaps;
+       FFCodecRemaps audio_codec_remaps;
        char file_format[BCTEXTLEN];
        int fflags;
 
@@ -381,14 +412,17 @@ public:
        int ff_coded_width(int stream);
        int ff_coded_height(int stream);
        float ff_aspect_ratio(int stream);
+       int ff_color_range(int stream);
+       int ff_color_space(int stream);
        double ff_frame_rate(int stream);
-       const char *ff_video_format(int stream);
+       const char *ff_video_codec(int stream);
        int64_t ff_video_frames(int stream);
        int ff_video_pid(int stream);
        int ff_video_mpeg_color_range(int stream);
 
        int ff_cpus();
        const char *ff_hw_dev();
+       Preferences *ff_prefs();
        void dump_context(AVCodecContext *ctx);
 };