X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fffmpeg.h;h=4f1624cee5c73558233cf2ec00c8bd4169d228af;hp=100d80f556e48856f9c25d8ffa2f4632514ad517;hb=54b918a8b84f666bf32548ebd12b93908061d2a6;hpb=676954c909c19080350cb159fb6be7ec65fd3ef6 diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h index 100d80f5..4f1624ce 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.h +++ b/cinelerra-5.1/cinelerra/ffmpeg.h @@ -37,6 +37,8 @@ extern "C" { #include "libavutil/pixdesc.h" #include "libswresample/swresample.h" #include "libswscale/swscale.h" +#include "libavutil/parseutils.h" +#include "libavutil/timecode.h" } class FFPacket { @@ -97,11 +99,12 @@ public: virtual int decode_frame(AVFrame *frame) = 0; virtual int encode_frame(AVFrame *frame) = 0; virtual int init_frame(AVFrame *frame) = 0; - virtual int create_filter(const char *filter_spec, AVCodecParameters *avpar) = 0; + virtual int create_filter(const char *filter_spec) = 0; virtual void load_markers() = 0; virtual IndexMarks *get_markers() = 0; - int create_filter(const char *filter_spec); - int load_filter(AVFrame *frame); + int insert_filter(const char *name, const char *arg, const char *inst_name=0); + int config_filters(const char *filter_spec, AVFilterContext *fsrc); + virtual int load_filter(AVFrame *frame); int read_filter(AVFrame *frame); int read_frame(AVFrame *frame); int open_stats_file(); @@ -115,10 +118,13 @@ public: AVFormatContext *fmt_ctx; AVCodecContext *avctx; - AVFilterContext *buffersink_ctx; + AVFilterContext *filt_ctx; + int filt_id; AVFilterContext *buffersrc_ctx; + AVFilterContext *buffersink_ctx; AVFilterGraph *filter_graph; AVFrame *frame, *fframe; + AVFrame *probe_frame; AVBSFContext *bsfc; FFPacket ipkt; @@ -132,7 +138,7 @@ public: int64_t seek_pos, curr_pos; int fidx; int reading, writing; - int seeked, eof; + int seeking, seeked, eof; int hw_pixfmt; AVBufferRef *hw_device_ctx; @@ -174,7 +180,7 @@ public: int load_history(uint8_t **data, int len); int decode_frame(AVFrame *frame); int encode_frame(AVFrame *frame); - int create_filter(const char *filter_spec, AVCodecParameters *avpar); + int create_filter(const char *filter_spec); void load_markers(); IndexMarks *get_markers(); @@ -244,25 +250,31 @@ public: 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); + int create_filter(const char *filter_spec); void load_markers(); IndexMarks *get_markers(); int init_frame(AVFrame *picture); int load(VFrame *vframe, int64_t pos); + int probe(int64_t pos); int video_seek(int64_t pos); int encode(VFrame *vframe); int drain(); + int convert_hw_frame(AVFrame *ifrm, AVFrame *ofrm); + int load_filter(AVFrame *frame); + double get_rotation_angle(); + int flip(double theta); int idx; double frame_rate; - int width, height; + int width, height, transpose; int64_t length; float aspect_ratio; int interlaced; int top_field_first; int color_space, color_range; + struct SwsContext *fconvert_ctx; }; class FFCodecRemap @@ -281,6 +293,38 @@ public: int update(AVCodecID &codec_id, AVCodec *&decoder); }; +// for get_initial_timecode auto deletes +class avFrame { + AVFrame *frm; +public: + avFrame() { frm = av_frame_alloc(); } + ~avFrame() { av_frame_free(&frm); } + operator AVFrame *() { return frm; } + AVFrame *operator ->() { return frm; } +}; + +class avPacket { + AVPacket pkt; +public: + avPacket() { + av_init_packet(&pkt); + pkt.data = 0; pkt.size = 0; + } + ~avPacket() { av_packet_unref(&pkt); } + operator AVPacket *() { return &pkt; } + AVPacket *operator ->() { return &pkt; } +}; + +class avCodecContext { + AVCodecContext *avctx; +public: + avCodecContext(AVCodecContext *ctx) { avctx = ctx; } + ~avCodecContext() { avcodec_free_context(&avctx); } + operator AVCodecContext *() { return avctx; } + AVCodecContext *operator ->() { return avctx; } +}; + + class FFMPEG : public Thread { public: static Mutex fflock; @@ -288,7 +332,7 @@ public: static void ff_unlock() { fflock.unlock(); } int check_sample_rate(AVCodec *codec, int sample_rate); - AVRational check_frame_rate(AVCodec *codec, double frame_rate); + AVRational check_frame_rate(const AVRational *p, double frame_rate); AVRational to_sample_aspect_ratio(Asset *asset); AVRational to_time_base(int sample_rate); static int get_fmt_score(AVSampleFormat dst_fmt, AVSampleFormat src_fmt); @@ -325,6 +369,10 @@ public: static double to_secs(int64_t time, AVRational time_base); int info(char *text, int len); + void put_cache_frame(VFrame *frame, int64_t position); + int get_use_cache(); + void purge_cache(); + int init_decoder(const char *filename); int open_decoder(); int init_encoder(const char *filename); @@ -333,8 +381,10 @@ public: int total_audio_channels(); int total_video_channels(); + double get_initial_timecode(int data_type, int channel, double frame_rate); int audio_seek(int ch, int64_t pos); + int video_probe(int64_t pos); int video_seek(int layer, int64_t pos); int decode(int chn, int64_t pos, double *samples, int len); @@ -386,9 +436,11 @@ public: int decoding, encoding; int has_audio, has_video; + int interlace_from_codec; FFMPEG(FileBase *file_base=0); ~FFMPEG(); + AVCodecContext *activate_decoder(AVStream *st); int scan(IndexState *index_state, int64_t *scan_position, int *canceled); int ff_audio_stream(int channel) { return astrm_index[channel].st_idx; } @@ -414,11 +466,14 @@ public: float ff_aspect_ratio(int stream); int ff_color_range(int stream); int ff_color_space(int stream); + int ff_interlace(int stream); double ff_frame_rate(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); + double ff_get_timecode(char *str, AVRational rate, double pos); + static double get_timecode(const char *path, int data_type, int channel, double rate); int ff_cpus(); const char *ff_hw_dev();