#!/bin/bash
./autogen.sh
-./configure --with-single-user
+./configure --with-single-user --with-opencv=sta,tar=http://192.168.1.8/opencv-20180401.tgz
make 2>&1 | tee log
make install
mv Makefile Makefile.cfg
{
char *path = av[1];
if( mkbdmv(path) ) return 1;
- av_register_all();
av_log_set_level(AV_LOG_FATAL);
//av_log_set_level(AV_LOG_VERBOSE);
//av_log_set_level(AV_LOG_DEBUG);
out->draw_line(x2,y2-r, x2-r,y2);
out->draw_line(x0,y2-r, x0+r,y2);
}
+ out->set_stiple(0);
}
int ret = 0;
// this should be avformat_copy_context(), but no copy avail
ret = avformat_open_input(&fmt_ctx,
- ffmpeg->fmt_ctx->filename, ffmpeg->fmt_ctx->iformat, &copts);
+ ffmpeg->fmt_ctx->url, ffmpeg->fmt_ctx->iformat, &copts);
if( ret >= 0 ) {
ret = avformat_find_stream_info(fmt_ctx, 0);
st = fmt_ctx->streams[fidx];
ret = AVERROR(ENOMEM);
}
if( ret >= 0 ) {
- av_codec_set_pkt_timebase(avctx, st->time_base);
- if( decoder->capabilities & AV_CODEC_CAP_DR1 )
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
avcodec_parameters_to_context(avctx, st->codecpar);
if( !av_dict_get(copts, "threads", NULL, 0) )
avctx->thread_count = ffmpeg->ff_cpus();
ff_err(ret, "FFAudioStream::decode_frame: Could not read audio frame\n");
return -1;
}
- int64_t pkt_ts = av_frame_get_best_effort_timestamp(frame);
+ int64_t pkt_ts = frame->best_effort_timestamp;
if( pkt_ts != AV_NOPTS_VALUE )
curr_pos = ffmpeg->to_secs(pkt_ts - nudge, st->time_base) * sample_rate + 0.5;
return 1;
{
if( writing >= 0 ) return writing;
if( !avctx->codec ) return writing = 0;
- frame_sz = avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE ?
+ frame_sz = avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE ?
10000 : avctx->frame_size;
return FFStream::encode_activate();
}
ff_err(ret, "FFVideoStream::decode_frame: Could not read video frame\n");
return -1;
}
- int64_t pkt_ts = av_frame_get_best_effort_timestamp(frame);
+ int64_t pkt_ts = frame->best_effort_timestamp;
if( pkt_ts != AV_NOPTS_VALUE )
curr_pos = ffmpeg->to_secs(pkt_ts - nudge, st->time_base) * frame_rate + 0.5;
return 1;
{
int ret = convert_cmodel(frame, ifp);
if( ret > 0 ) {
- const AVDictionary *src = av_frame_get_metadata(ifp);
+ const AVDictionary *src = ifp->metadata;
AVDictionaryEntry *t = NULL;
BC_Hash *hp = frame->get_params();
//hp->clear();
int ret = convert_pixfmt(frame, ofp);
if( ret > 0 ) {
BC_Hash *hp = frame->get_params();
- AVDictionary **dict = avpriv_frame_get_metadatap(ofp);
+ AVDictionary **dict = &ofp->metadata;
//av_dict_free(dict);
for( int i=0; i<hp->size(); ++i ) {
char *key = hp->get_key(i), *val = hp->get_value(i);
int FFMPEG::init_decoder(const char *filename)
{
ff_lock("FFMPEG::init_decoder");
- av_register_all();
char file_opts[BCTEXTLEN];
char *bp = strrchr(strcpy(file_opts, filename), '/');
char *sp = strrchr(!bp ? file_opts : bp, '.');
int FFMPEG::open_decoder()
{
struct stat st;
- if( stat(fmt_ctx->filename, &st) < 0 ) {
- eprintf(_("can't stat file: %s\n"), fmt_ctx->filename);
+ if( stat(fmt_ctx->url, &st) < 0 ) {
+ eprintf(_("can't stat file: %s\n"), fmt_ctx->url);
return 1;
}
return 1;
}
ff_lock("FFMPEG::init_encoder");
- av_register_all();
char format[BCSTRLEN];
if( get_format(format, "format", file_format) )
strcpy(format, file_format);
ctx->qmin = ctx->qmax = asset->ff_audio_quality;
ctx->mb_lmin = ctx->qmin * FF_QP2LAMBDA;
ctx->mb_lmax = ctx->qmax * FF_QP2LAMBDA;
- ctx->flags |= CODEC_FLAG_QSCALE;
+ ctx->flags |= AV_CODEC_FLAG_QSCALE;
char arg[BCSTRLEN];
av_dict_set(&sopts, "flags", "+qscale", 0);
sprintf(arg, "%d", asset->ff_audio_quality);
ctx->qmin = ctx->qmax = asset->ff_video_quality;
ctx->mb_lmin = ctx->qmin * FF_QP2LAMBDA;
ctx->mb_lmax = ctx->qmax * FF_QP2LAMBDA;
- ctx->flags |= CODEC_FLAG_QSCALE;
+ ctx->flags |= AV_CODEC_FLAG_QSCALE;
char arg[BCSTRLEN];
av_dict_set(&sopts, "flags", "+qscale", 0);
sprintf(arg, "%d", asset->ff_video_quality);
}
if( !ret ) {
if( fmt_ctx->oformat->flags & AVFMT_GLOBALHEADER )
- ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
if( fst->stats_filename && (ret=fst->init_stats_file()) )
eprintf(_("error: stats file = %s\n"), fst->stats_filename);
}
if( encoding < 0 ) {
encoding = 0;
if( !(fmt_ctx->flags & AVFMT_NOFILE) &&
- (ret=avio_open(&fmt_ctx->pb, fmt_ctx->filename, AVIO_FLAG_WRITE)) < 0 ) {
+ (ret=avio_open(&fmt_ctx->pb, fmt_ctx->url, AVIO_FLAG_WRITE)) < 0 ) {
ff_err(ret, "FFMPEG::encode_activate: err opening : %s\n",
- fmt_ctx->filename);
+ fmt_ctx->url);
return -1;
}
while( --pi >= 0 && fmt_ctx->programs[pi]->id != prog_id );
AVDictionary **meta = &prog->metadata;
av_dict_set(meta, "service_provider", "cin5", 0);
- const char *path = fmt_ctx->filename, *bp = strrchr(path,'/');
+ const char *path = fmt_ctx->url, *bp = strrchr(path,'/');
if( bp ) path = bp + 1;
av_dict_set(meta, "title", path, 0);
ret = avformat_write_header(fmt_ctx, &fopts);
if( ret < 0 ) {
ff_err(ret, "FFMPEG::encode_activate: write header failed %s\n",
- fmt_ctx->filename);
+ fmt_ctx->url);
return -1;
}
av_dict_free(&fopts);
int FFVideoStream::create_filter(const char *filter_spec, AVCodecParameters *avpar)
{
- avfilter_register_all();
const char *sp = filter_spec;
char filter_name[BCSTRLEN], *np = filter_name;
int i = sizeof(filter_name);
while( --i>=0 && *sp!=0 && !strchr(" \t:=,",*sp) ) *np++ = *sp++;
*np = 0;
- AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
+ const AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_VIDEO ) {
ff_err(AVERROR(EINVAL), "FFVideoStream::create_filter: %s\n", filter_spec);
return -1;
}
filter_graph = avfilter_graph_alloc();
- AVFilter *buffersrc = avfilter_get_by_name("buffer");
- AVFilter *buffersink = avfilter_get_by_name("buffersink");
+ const AVFilter *buffersrc = avfilter_get_by_name("buffer");
+ const AVFilter *buffersink = avfilter_get_by_name("buffersink");
int ret = 0; char args[BCTEXTLEN];
AVPixelFormat pix_fmt = (AVPixelFormat)avpar->format;
int FFAudioStream::create_filter(const char *filter_spec, AVCodecParameters *avpar)
{
- avfilter_register_all();
const char *sp = filter_spec;
char filter_name[BCSTRLEN], *np = filter_name;
int i = sizeof(filter_name);
while( --i>=0 && *sp!=0 && !strchr(" \t:=,",*sp) ) *np++ = *sp++;
*np = 0;
- AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
+ const AVFilter *filter = !filter_name[0] ? 0 : avfilter_get_by_name(filter_name);
if( !filter || avfilter_pad_get_type(filter->inputs,0) != AVMEDIA_TYPE_AUDIO ) {
ff_err(AVERROR(EINVAL), "FFAudioStream::create_filter: %s\n", filter_spec);
return -1;
}
filter_graph = avfilter_graph_alloc();
- AVFilter *buffersrc = avfilter_get_by_name("abuffer");
- AVFilter *buffersink = avfilter_get_by_name("abuffersink");
+ const AVFilter *buffersrc = avfilter_get_by_name("abuffer");
+ const AVFilter *buffersink = avfilter_get_by_name("abuffersink");
int ret = 0; char args[BCTEXTLEN];
AVSampleFormat sample_fmt = (AVSampleFormat)avpar->format;
snprintf(args, sizeof(args),
if( !result && wr )
{
- //avcodec_init();
- avcodec_register_all();
codec = avcodec_find_encoder(AV_CODEC_ID_AC3);
if(!codec)
{
}
FileSystem fs;
- int64_t file_bytes = fs.get_size(ff->fmt_ctx->filename);
+ int64_t file_bytes = fs.get_size(ff->fmt_ctx->url);
char *index_path = index_file->index_filename;
int canceled = 0;
delete ffilt;
}
-bool PluginFClient::is_audio(AVFilter *fp)
+bool PluginFClient::is_audio(const AVFilter *fp)
{
if( !fp->outputs ) return 0;
if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
if( avfilter_pad_get_type(fp->inputs, 0) != AVMEDIA_TYPE_AUDIO ) return 0;
return 1;
}
-bool PluginFClient::is_video(AVFilter *fp)
+bool PluginFClient::is_video(const AVFilter *fp)
{
if( !fp->outputs ) return 0;
if( avfilter_pad_count(fp->outputs) > 1 ) return 0;
{
AVFilterContext *fctx = ffilt->fctx;
AVFilterLink **links = !fctx->nb_inputs ? 0 : fctx->inputs;
- return !links ? 0 : avfilter_link_get_channels(links[0]);
+ return !links ? 0 : links[0]->channels;
}
int PluginFAClient::get_outchannels()
{
AVFilterContext *fctx = ffilt->fctx;
AVFilterLink **links = !fctx->nb_outputs ? 0 : fctx->outputs;
- return !links ? 0 : avfilter_link_get_channels(links[0]);
+ return !links ? 0 : links[0]->channels;
}
int PluginFAClient::process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate)
PluginClient *PluginServer::new_ffmpeg_plugin()
{
- AVFilter *filter = avfilter_get_by_name(ff_name);
+ const AVFilter *filter = avfilter_get_by_name(ff_name);
if( !filter ) return 0;
PluginFClient *ffmpeg =
PluginFClient::is_audio(filter) ?
void MWindow::init_ffmpeg_index(MWindow *mwindow, Preferences *preferences, FILE *fp)
{
PluginFLogLevel errs(AV_LOG_ERROR);
- const AVFilter *filter = 0;
- while( (filter=avfilter_next(filter)) != 0 ) {
+ const AVFilter *filter = 0; void *idx = 0;
+ while( (filter=av_filter_iterate(&idx)) != 0 ) {
+//printf("%s\n",filter->name);
PluginServer *server = new_ffmpeg_server(mwindow, filter->name);
if( server ) {
int result = server->open_plugin(1, preferences, 0, 0);
void MWindow::init_ffmpeg()
{
- av_register_all();
- avfilter_register_all();
}
class PluginFFilter {
PluginFFilter(PluginFFilter &that) {} //disable assign/copy
public:
- AVFilter *filter;
+ const AVFilter *filter;
AVFilterGraph *graph;
AVFilterContext *fctx;
PluginFClient(PluginClient *plugin, const char *name);
~PluginFClient();
- static bool is_audio(AVFilter *fp);
- static bool is_video(AVFilter *fp);
+ static bool is_audio(const AVFilter *fp);
+ static bool is_video(const AVFilter *fp);
int64_t get_source_position() {
return plugin->get_source_position();
CFG_CFLAGS+=" -pthread -Wall"
# misguided pedantic warnings
CFG_CFLAGS+=" -Wno-unused-result"
-CFG_CFLAGS+=" -Wno-stringop-truncation"
CFG_CFLAGS+=" -Wno-stringop-overflow"
CFG_CFLAGS+=" -Wno-format-truncation"
CFG_CFLAGS+=" -Wno-format-overflow"
[ libAACdec/include libAACenc/include libSYS/include ])
PKG_3RD([ffmpeg],[yes],
- [ffmpeg-3.4.2],
+ [ffmpeg-4.0],
[ libavutil/libavutil.a \
libavcodec/libavcodec.a \
libpostproc/libpostproc.a \
#decimate
deflate
dejudder
-delogo x=1:y=1:w=1:h=1:band=1:show=0
+delogo x=10:y=10:w=10:h=10:show=1
deshake
#detelecine
dilation
; new in 3.4.1
#acopy
bitplanenoise
-boxblur
ciescope
crossfeed
deflicker
pixscope
pseudocolor
roberts
-smartblur
#superequalizer
#surround
tlut2
#tonemap
#vmafmotion
-; in git
+; new in 4.0
+acontrast
#afir
-#headphone
+#aiir
#convolve
+#deconvolve
+drmeter
+entropy
+fillborders
+#headphone
+hilbert
+mcompand
+#mix
+normalize
+setrange
#unpremultiply
+vfrdet
# plugin_dirs is translated in awindowgui.C, update if changed.
plugin_dirs := themes
-themes := theme_bright theme_suv theme_blond theme_blue theme_blue_dot \
- theme_hulk theme_pinklady theme_unflat theme_blond_cv
+themes := \
+ theme_blond \
+ theme_blond_cv \
+ theme_blue \
+ theme_blue_dot \
+ theme_bright \
+ theme_hulk \
+ theme_pinklady \
+ theme_suv \
+ theme_unflat \
-plugin_dirs += audio_transitions
-audio_transitions := crossfade
+plugin_dirs += video
+video := \
+ 1080to480 \
+ 1080to540 \
+ 720to480 \
+ aging \
+ bandslide \
+ bandwipe \
+ bluebanana \
+ blur \
+ brightness \
+ burn \
+ C41 \
+ chromakey \
+ chromakeyhsv \
+ color3way \
+ colorbalance \
+ crikey \
+ crossfade \
+ decimate \
+ deinterlace \
+ deinterlace-cv \
+ delayvideo \
+ denoisemjpeg \
+ denoisevideo \
+ descratch \
+ diffkey \
+ dissolve \
+ dot \
+ downsample \
+ edge \
+ fieldframe \
+ flash \
+ flip \
+ framefield \
+ freezeframe \
+ gamma \
+ gradient \
+ greycstoration \
+ histeq \
+ histogram \
+ histogram_bezier \
+ holo \
+ huesaturation \
+ interpolatepixels \
+ interpolatevideo \
+ invertvideo \
+ irissquare \
+ ivtc \
+ lens \
+ linearblur \
+ liveaudio \
+ livevideo \
+ loopvideo \
+ motion \
+ motion2 \
+ motion51 \
+ motionblur \
+ motion-cv \
+ motion-hv \
+ oil \
+ overlay \
+ perspective \
+ photoscale \
+ polar \
+ radialblur \
+ reframe \
+ reframert \
+ reroute \
+ reversevideo \
+ rgb601 \
+ rgbshift \
+ rotate \
+ rumbler \
+ scale \
+ scaleratio \
+ seltempavg \
+ shapewipe \
+ sharpen \
+ shiftinterlace \
+ slide \
+ spherecam \
+ svg \
+ swapchannels \
+ swapframes \
+ threshold \
+ timeavg \
+ timefront \
+ titler \
+ translate \
+ unsharp \
+ videoscope \
+ wave \
+ whirl \
+ wipe \
+ yuv \
+ yuv411 \
+ yuvshift \
+ zoom \
+ zoomblur \
-plugin_dirs += video_transitions
-video_transitions := bandslide bandwipe dissolve flip irissquare \
- shapewipe slide wipe zoom
+plugin_dirs += audio
+audio := \
+ audioscope \
+ cdripper \
+ compressor \
+ dcoffset \
+ delayaudio \
+ denoise \
+ denoisefft \
+ despike \
+ echo \
+ echocancel \
+ freeverb \
+ gain \
+ graphic \
+ interpolateaudio \
+ invertaudio \
+ leveleffect \
+ loopaudio \
+ normalize \
+ overlayaudio \
+ parametric \
+ pitch \
+ removegaps \
+ resample \
+ resamplert \
+ reverb \
+ reverseaudio \
+ spectrogram \
+ synthesizer \
+ timestretch \
+ timestretchrt \
+ vocoder \
-plugin_dirs += transforms
-transforms := 1080to480 1080to540 720to480 lens perspective photoscale \
- polar rotate scale translate whirl scaleratio
-
-plugin_dirs += colors
-colors := brightness bluebanana C41 color3way colorbalance huesaturation \
- gamma gradient histeq histogram histogram_bezier threshold
-
-plugin_dirs += exotic
-exotic := aging burn dot holo oil edge spherecam \
- findobj flowobj gaborobj moveobj stylizeobj puzzleobj
-
-plugin_dirs += audio_tools
-audio_tools := audioscope cdripper compressor dcoffset delayaudio \
- denoisefft denoise despike echocancel echo freeverb \
- gain graphic interpolateaudio invertaudio leveleffect loopaudio \
- normalize overlayaudio parametric pitch removegaps resample \
- resamplert reverb reverseaudio synthesizer timestretch timestretchrt \
- spectrogram vocoder
-
-plugin_dirs += video_tools
-video_tools := blur decimate delayvideo denoisemjpeg denoisevideo downsample \
- fieldframe flash framefield freezeframe greycstoration interpolatepixels \
- interpolatevideo invertvideo linearblur loopvideo \
- motion2 motionblur motion motion-cv motion-hv motion51 \
- overlay radialblur reframe reframert reroute reversevideo \
- rumbler seltempavg sharpen svg titler timeavg timefront \
- unsharp videoscope wave zoomblur descratch
-
-plugin_dirs += blending
-blending := crikey chromakeyhsv chromakey diffkey
-
-plugin_dirs += tv_effects
-tv_effects := deinterlace-cv deinterlace ivtc liveaudio livevideo rgb601 \
- rgbshift shiftinterlace swapchannels swapframes yuv yuv411 yuvshift
+plugin_dirs += opencv
+opencv := \
+ findobj \
+ flowobj \
+ gaborobj \
+ moveobj \
+ puzzleobj \
+ stylizeobj \
$(foreach dir,$(plugin_dirs),$(foreach plugin,$($(dir)), $(eval $(plugin):=$(dir))))
algorithm = NO_ALGORITHM;
use_flann = 1;
mode = MODE_QUADRILATERAL;
+ draw_match = 0;
+ aspect = 1;
scale = 1;
translate = 1;
rotate = 1;
algorithm == that.algorithm &&
use_flann == that.use_flann &&
mode == that.mode &&
+ aspect == that.aspect &&
scale == that.scale &&
translate == that.translate &&
rotate == that.rotate &&
draw_keypoints == that.draw_keypoints &&
+ draw_match == that.draw_match &&
draw_scene_border == that.draw_scene_border &&
replace_object == that.replace_object &&
draw_object_border == that.draw_object_border &&
algorithm = that.algorithm;
use_flann = that.use_flann;
mode = that.mode;
+ aspect = that.aspect;
scale = that.scale;
translate = that.translate;
rotate = that.rotate;
draw_keypoints = that.draw_keypoints;
+ draw_match = that.draw_match;
draw_scene_border = that.draw_scene_border;
replace_object = that.replace_object;
draw_object_border = that.draw_object_border;
scene_layer = 1;
replace_layer = 2;
- border_x1 = 0; border_y1 = 0;
- border_x2 = 0; border_y2 = 0;
- border_x3 = 0; border_y3 = 0;
- border_x4 = 0; border_y4 = 0;
-
- obj_x1 = 0; obj_y1 = 0;
- obj_x2 = 0; obj_y2 = 0;
- obj_x3 = 0; obj_y3 = 0;
- obj_x4 = 0; obj_y4 = 0;
+ match_x1 = 0; match_y1 = 0;
+ match_x2 = 0; match_y2 = 0;
+ match_x3 = 0; match_y3 = 0;
+ match_x4 = 0; match_y4 = 0;
+ shape_x1 = 0; shape_y1 = 0;
+ shape_x2 = 0; shape_y2 = 0;
+ shape_x3 = 0; shape_y3 = 0;
+ shape_x4 = 0; shape_y4 = 0;
+ out_x1 = 0; out_y1 = 0;
+ out_x2 = 0; out_y2 = 0;
+ out_x3 = 0; out_y3 = 0;
+ out_x4 = 0; out_y4 = 0;
init_border = 1;
}
output.tag.set_property("ALGORITHM", config.algorithm);
output.tag.set_property("USE_FLANN", config.use_flann);
output.tag.set_property("MODE", config.mode);
+ output.tag.set_property("ASPECT", config.aspect);
output.tag.set_property("SCALE", config.scale);
output.tag.set_property("TRANSLATE", config.translate);
output.tag.set_property("ROTATE", config.rotate);
output.tag.set_property("REPLACE_DX", config.replace_dx);
output.tag.set_property("REPLACE_DY", config.replace_dy);
output.tag.set_property("DRAW_KEYPOINTS", config.draw_keypoints);
+ output.tag.set_property("DRAW_MATCH", config.draw_match);
output.tag.set_property("DRAW_SCENE_BORDER", config.draw_scene_border);
output.tag.set_property("REPLACE_OBJECT", config.replace_object);
output.tag.set_property("DRAW_OBJECT_BORDER", config.draw_object_border);
config.algorithm = input.tag.get_property("ALGORITHM", config.algorithm);
config.use_flann = input.tag.get_property("USE_FLANN", config.use_flann);
config.mode = input.tag.get_property("MODE", config.mode);
+ config.aspect = input.tag.get_property("ASPECT", config.aspect);
config.scale = input.tag.get_property("SCALE", config.scale);
config.translate = input.tag.get_property("TRANSLATE", config.translate);
config.rotate = input.tag.get_property("ROTATE", config.rotate);
config.replace_dy = input.tag.get_property("REPLACE_DY", config.replace_dy);
config.drag_replace = input.tag.get_property("DRAG_REPLACE", config.drag_replace);
config.draw_keypoints = input.tag.get_property("DRAW_KEYPOINTS", config.draw_keypoints);
+ config.draw_match = input.tag.get_property("DRAW_MATCH", config.draw_match);
config.draw_scene_border = input.tag.get_property("DRAW_SCENE_BORDER", config.draw_scene_border);
config.replace_object = input.tag.get_property("REPLACE_OBJECT", config.replace_object);
config.draw_object_border = input.tag.get_property("DRAW_OBJECT_BORDER", config.draw_object_border);
vframe->draw_line(x1, y1, x2, y2);
}
+void FindObjMain::draw_quad(VFrame *vframe,
+ int x1, int y1, int x2, int y2,
+ int x3, int y3, int x4, int y4)
+{
+ int r = bmin(vframe->get_w(), vframe->get_h()) / 200 + 1;
+ for( int i=r; --i>0; ) {
+ draw_line(vframe, x1+i, y1+i, x2, y2);
+ draw_line(vframe, x1-i, y1-i, x2, y2);
+ draw_line(vframe, x2+i, y2+i, x3, y3);
+ draw_line(vframe, x2-i, y2-i, x3, y3);
+ draw_line(vframe, x3+i, y3+i, x4, y4);
+ draw_line(vframe, x3-i, y3-i, x4, y4);
+ draw_line(vframe, x4+i, y4+i, x1, y1);
+ draw_line(vframe, x4-i, y4-i, x1, y1);
+ }
+ draw_line(vframe, x1, y1, x2, y2);
+ draw_line(vframe, x2, y2, x3, y3);
+ draw_line(vframe, x3, y3, x4, y4);
+ draw_line(vframe, x4, y4, x1, y1);
+ for( int i=r; --i>0; )
+ draw_circle(vframe, x1, y1, i);
+}
+
void FindObjMain::draw_rect(VFrame *vframe, int x1, int y1, int x2, int y2)
{
- --x2; --y2;
- draw_line(vframe, x1, y1, x2, y1);
- draw_line(vframe, x2, y1, x2, y2);
- draw_line(vframe, x2, y2, x1, y2);
- draw_line(vframe, x1, y2, x1, y1);
+ int r = bmin(vframe->get_w(), vframe->get_h()) / 200 + 1;
+ for( int i=r; --i>0; ) {
+ --x2; --y2;
+ draw_line(vframe, x1, y1, x2, y1);
+ draw_line(vframe, x2, y1, x2, y2);
+ draw_line(vframe, x2, y2, x1, y2);
+ draw_line(vframe, x1, y2, x1, y1);
+ ++x1; ++y1;
+ }
}
void FindObjMain::draw_circle(VFrame *vframe, int x, int y, int r)
}
ptV src, dst;
- float obj_x1 = 0, obj_x2 = object_w;
- float obj_y1 = 0, obj_y2 = object_h;
- src.push_back(Point2f(obj_x1,obj_y1));
- src.push_back(Point2f(obj_x2,obj_y1));
- src.push_back(Point2f(obj_x2,obj_y2));
- src.push_back(Point2f(obj_x1,obj_y2));
+ float out_x1 = 0, out_x2 = object_w;
+ float out_y1 = 0, out_y2 = object_h;
+ src.push_back(Point2f(out_x1,out_y1));
+ src.push_back(Point2f(out_x2,out_y1));
+ src.push_back(Point2f(out_x2,out_y2));
+ src.push_back(Point2f(out_x1,out_y2));
perspectiveTransform(src, dst, H);
- border_x1 = dst[0].x; border_y1 = dst[0].y;
- border_x2 = dst[1].x; border_y2 = dst[1].y;
- border_x3 = dst[2].x; border_y3 = dst[2].y;
- border_x4 = dst[3].x; border_y4 = dst[3].y;
+ match_x1 = dst[0].x + scene_x; match_y1 = dst[0].y + scene_y;
+ match_x2 = dst[1].x + scene_x; match_y2 = dst[1].y + scene_y;
+ match_x3 = dst[2].x + scene_x; match_y3 = dst[2].y + scene_y;
+ match_x4 = dst[3].x + scene_x; match_y4 = dst[3].y + scene_y;
}
-static double area(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
-{ // quadrelateral area
+static double area(float x1, float y1, float x2, float y2,
+ float x3, float y3, float x4, float y4)
+{ // quadrelateral area, sign is +ccw,-cw, use abs
double dx1 = x3-x1, dy1 = y3-y1;
double dx2 = x4-x2, dy2 = y4-y2;
- return 0.5 * abs(dx1 * dy2 - dx2 * dy1);
+ return 0.5 * (dx1 * dy2 - dx2 * dy1);
}
static double dist(float x1,float y1, float x2, float y2)
{
double dx = x2-x1, dy = y2-y1;
return sqrt(dx*dx + dy*dy);
}
+static int intersects(double x1, double y1, double x2, double y2,
+ double x3, double y3, double x4, double y4)
+{
+ double dx12 = x2 - x1, dy12 = y2 - y1;
+ double dx34 = x4 - x3, dy34 = y4 - y3;
+ double d = dx12*dy34 - dx34*dy12;
+ if( !d ) return 0; // parallel
+ double dx13 = x3 - x1, dy13 = y3 - y1;
+ double u = (dx13*dy34 - dx34*dy13) / d;
+ if( u < 0 || u > 1 ) return 0;
+ double v = (dx13*dy12 - dx12*dy13) / d;
+ if( v < 0 || v > 1 ) return 0;
+ return 1;
+}
/*
* 4---------3 1---------2
{
if( config.mode == MODE_NONE ) return;
const double pi = M_PI;
- double x1 = border_x1, y1 = border_y1;
- double x2 = border_x2, y2 = border_y2;
- double x3 = border_x3, y3 = border_y3;
- double x4 = border_x4, y4 = border_y4;
+ double x1 = match_x1, y1 = match_y1;
+ double x2 = match_x2, y2 = match_y2;
+ double x3 = match_x3, y3 = match_y3;
+ double x4 = match_x4, y4 = match_y4;
+ double ia = area(x1,y1, x2,y2, x3,y3, x4,y4);
// centroid
double cx = (x1 + x2 + x3 + x4) / 4;
double cy = (y1 + y2 + y3 + y4) / 4;
// centered
x1 -= cx; x2 -= cx; x3 -= cx; x4 -= cx;
y1 -= cy; y2 -= cy; y3 -= cy; y4 -= cy;
+// bowtied
+ if( intersects(x1,y1, x2,y2, x3,y3, x4,y4) ) {
+ double x = x2, y = y2;
+ x2 = x3; y2 = y3;
+ x3 = x; y3 = y;
+ }
+ else if( intersects(x1,y1, x4,y4, x3,y3, x2,y2) ) {
+ double x = x4, y = y4;
+ x4 = x3; y4 = y3;
+ x3 = x; y3 = y;
+ }
+
// rotation, if mode is quad: reverse rotate
double r = 0;
- if( (config.mode == MODE_QUADRILATERAL) ^ config.rotate ) {
+ if( (config.mode == MODE_QUADRILATERAL) ^ (config.rotate != 0) ) {
// edge centers
double cx12 = (x1 + x2) / 2, cy12 = (y1 + y2) / 2;
double cx23 = (x2 + x3) / 2, cy23 = (y2 + y3) / 2;
double a12 = a2 - a1, a23 = a3 - a2;
double a34 = a4 - a3, a41 = a1 - a4;
double dt = (a12 - a23 + a34 - a41)/4;
+// mirrored
+ if( ia < 0 ) { ia = -ia; dt = -dt; r = -r; }
switch( config.mode ) {
case MODE_SQUARE:
case MODE_RHOMBUS:
case MODE_QUADRILATERAL:
break;
}
+// aspect
+ if( !config.aspect ) {
+ double cx12 = (x1 + x2) / 2, cy12 = (y1 + y2) / 2;
+ double cx23 = (x2 + x3) / 2, cy23 = (y2 + y3) / 2;
+ double cx34 = (x3 + x4) / 2, cy34 = (y3 + y4) / 2;
+ double cx41 = (x4 + x1) / 2, cy41 = (y4 + y1) / 2;
+ double iw = dist(cx41,cy41, cx23,cy23);
+ double ih = dist(cx12,cy12, cx34,cy34);
+ double ow = object_w, oh = object_h;
+ double sx = iw && ih ? sqrt((ih*ow)/(iw*oh)) : 1;
+ double sy = sx ? 1 / sx : 1;
+ x1 *= sx; x2 *= sx; x3 *= sx; x4 *= sx;
+ y1 *= sy; y2 *= sy; y3 *= sy; y4 *= sy;
+ }
// rotation
if( r ) {
double ct = cos(r), st = sin(r), x, y;
x = x4*ct + y4*st; y = y4*ct - x4*st; x4 = x; y4 = y;
}
// scaling
- double ia = !config.scale ? object_w * object_h :
- area(border_x1,border_y1, border_x2,border_y2,
- border_x3,border_y3, border_x4,border_y4);
- double oa = area(x1,y1, x2,y2, x3,y3, x4,y4);
+ ia = !config.scale ? object_w * object_h : ia;
+ double oa = abs(area(x1,y1, x2,y2, x3,y3, x4,y4));
double sf = oa ? sqrt(ia / oa) : 0;
x1 *= sf; x2 *= sf; x3 *= sf; x4 *= sf;
y1 *= sf; y2 *= sf; y3 *= sf; y4 *= sf;
x1 += ox; x2 += ox; x3 += ox; x4 += ox;
y1 += oy; y2 += oy; y3 += oy; y4 += oy;
- border_x1 = x1; border_y1 = y1;
- border_x2 = x2; border_y2 = y2;
- border_x3 = x3; border_y3 = y3;
- border_x4 = x4; border_y4 = y4;
+ shape_x1 = x1; shape_y1 = y1;
+ shape_x2 = x2; shape_y2 = y2;
+ shape_x3 = x3; shape_y3 = y3;
+ shape_x4 = x4; shape_y4 = y4;
}
int FindObjMain::process_buffer(VFrame **frame, int64_t start_position, double frame_rate)
scene = frame[scene_layer];
replace = frame[replace_layer];
- border_x1 = obj_x1; border_y1 = obj_y1;
- border_x2 = obj_x2; border_y2 = obj_y2;
- border_x3 = obj_x3; border_y3 = obj_y3;
- border_x4 = obj_x4; border_y4 = obj_y4;
+ shape_x1 = out_x1; shape_y1 = out_y1;
+ shape_x2 = out_x2; shape_y2 = out_y2;
+ shape_x3 = out_x3; shape_y3 = out_y3;
+ shape_x4 = out_x4; shape_y4 = out_y4;
if( scene_w > 0 && scene_h > 0 && object_w > 0 && object_h > 0 ) {
process_match();
double w0 = init_border ? 1. : config.blend/100., w1 = 1. - w0;
init_border = 0;
- obj_x1 = border_x1*w0 + obj_x1*w1; obj_y1 = border_y1*w0 + obj_y1*w1;
- obj_x2 = border_x2*w0 + obj_x2*w1; obj_y2 = border_y2*w0 + obj_y2*w1;
- obj_x3 = border_x3*w0 + obj_x3*w1; obj_y3 = border_y3*w0 + obj_y3*w1;
- obj_x4 = border_x4*w0 + obj_x4*w1; obj_y4 = border_y4*w0 + obj_y4*w1;
+ out_x1 = shape_x1*w0 + out_x1*w1; out_y1 = shape_y1*w0 + out_y1*w1;
+ out_x2 = shape_x2*w0 + out_x2*w1; out_y2 = shape_y2*w0 + out_y2*w1;
+ out_x3 = shape_x3*w0 + out_x3*w1; out_y3 = shape_y3*w0 + out_y3*w1;
+ out_x4 = shape_x4*w0 + out_x4*w1; out_y4 = shape_y4*w0 + out_y4*w1;
// Replace object in the scene layer
if( config.replace_object ) {
int cpus1 = get_project_smp() + 1;
VFrame *temp = new_temp(w, h, scene->get_color_model());
temp->clear_frame();
affine->set_in_viewport(replace_x, replace_y, replace_w, replace_h);
+ float ix1 = replace_x, ix2 = ix1 + replace_w;
+ float iy1 = replace_y, iy2 = iy1 + replace_h;
float dx = replace_dx, dy = replace_dy;
- float x1 = obj_x1+dx, x2 = obj_x2+dx, x3 = obj_x3+dx, x4 = obj_x4+dx;
- float y1 = obj_y1-dy, y2 = obj_y2-dy, y3 = obj_y3-dy, y4 = obj_y4-dy;
- affine->set_matrix(
- replace_x, replace_y, replace_x+replace_w, replace_y+replace_h,
- x1,y1, x2,y2, x4,y4, x3,y3);
+ float ox1 = out_x1+dx, ox2 = out_x2+dx, ox3 = out_x3+dx, ox4 = out_x4+dx;
+ float oy1 = out_y1-dy, oy2 = out_y2-dy, oy3 = out_y3-dy, oy4 = out_y4-dy;
+ affine->set_matrix(ix1,iy1, ix2,iy2, ox1,oy1, ox2,oy2, ox4,oy4, ox3,oy3);
affine->process(temp, replace, 0,
AffineEngine::TRANSFORM, 0,0, 100,0, 100,100, 0,100, 1);
overlayer->overlay(scene, temp, 0,0, w,h, 0,0, w,h,
}
+ int wh = (w+h)>>8, ss = 1; while( wh>>=1 ) ss<<=1;
if( config.draw_scene_border ) {
- int wh = (w+h)>>8, ss = 1; while( wh>>=1 ) ss<<=1;
- scene->set_pixel_color(WHITE); scene->set_stiple(ss*2);
+ scene->set_stiple(ss*2);
+ scene->set_pixel_color(WHITE);
draw_rect(scene, scene_x, scene_y, scene_x+scene_w, scene_y+scene_h);
}
if( config.draw_object_border ) {
- int wh = (w+h)>>8, ss = 1; while( wh>>=1 ) ss<<=1;
- scene->set_pixel_color(YELLOW); scene->set_stiple(ss*3);
+ scene->set_stiple(ss*3);
+ scene->set_pixel_color(YELLOW);
draw_rect(scene, object_x, object_y, object_x+object_w, object_y+object_h);
}
if( config.draw_replace_border ) {
- int wh = (w+h)>>8, ss = 1; while( wh>>=1 ) ss<<=1;
- scene->set_pixel_color(GREEN); scene->set_stiple(ss*3);
+ scene->set_stiple(ss*3);
+ scene->set_pixel_color(GREEN);
draw_rect(scene, replace_x, replace_y, replace_x+replace_w, replace_y+replace_h);
}
+ scene->set_stiple(0);
if( config.draw_keypoints ) {
- scene->set_pixel_color(GREEN); scene->set_stiple(0);
+ scene->set_pixel_color(GREEN);
for( int i=0,n=obj_keypts.size(); i<n; ++i ) {
Point2f &pt = obj_keypts[i].pt;
int r = obj_keypts[i].size * 1.2/9 * 2;
int x = pt.x + object_x, y = pt.y + object_y;
draw_circle(scene, x, y, r);
}
- scene->set_pixel_color(RED); scene->set_stiple(0);
+ scene->set_pixel_color(RED);
for( int i=0,n=scn_keypts.size(); i<n; ++i ) {
Point2f &pt = scn_keypts[i].pt;
int r = scn_keypts[i].size * 1.2/9 * 2;
draw_circle(scene, x, y, r);
}
}
+ if( config.draw_match ) {
+ scene->set_pixel_color(BLUE);
+ draw_quad(scene, match_x1, match_y1, match_x2, match_y2,
+ match_x3, match_y3, match_x4, match_y4);
+ }
if( gui_open() ) {
if( config.drag_scene ) {
int64_t prev_frame, int64_t next_frame, int64_t current_frame);
void boundaries();
- int algorithm, use_flann;
+ int algorithm, use_flann, mode;
int drag_object, drag_scene, drag_replace;
float object_x, object_y, object_w, object_h;
float scene_x, scene_y, scene_w, scene_h;
float replace_x, replace_y, replace_w, replace_h;
float replace_dx, replace_dy;
- int mode, scale, translate, rotate;
- int draw_keypoints;
+ int aspect, scale, translate, rotate;
+ int draw_keypoints, draw_match;
int draw_scene_border;
int replace_object;
int draw_object_border;
VFrame *object, *scene, *replace;
static void draw_line(VFrame *vframe, int x1, int y1, int x2, int y2);
+ void draw_quad(VFrame *vframe,
+ int x1, int y1, int x2, int y2,
+ int x3, int y3, int x4, int y4);
static void draw_rect(VFrame *vframe, int x1, int y1, int x2, int y2);
static void draw_circle(VFrame *vframe, int x, int y, int r);
int scene_layer;
int replace_layer;
-// Latest coordinates of object in scene
- float border_x1, border_y1;
- float border_x2, border_y2;
- float border_x3, border_y3;
- float border_x4, border_y4;
+// Latest coordinates of match / shape / object in scene
+ float match_x1, match_y1, shape_x1, shape_y1, out_x1, out_y1;
+ float match_x2, match_y2, shape_x2, shape_y2, out_x2, out_y2;
+ float match_x3, match_y3, shape_x3, shape_y3, out_x3, out_y3;
+ float match_x4, match_y4, shape_x4, shape_y4, out_x4, out_y4;
// Coordinates of object in scene with blending
- float obj_x1, obj_y1;
- float obj_x2, obj_y2;
- float obj_x3, obj_y3;
- float obj_x4, obj_y4;
int init_border;
//opencv
FindObjWindow::FindObjWindow(FindObjMain *plugin)
- : PluginClientWindow(plugin, 500, 660, 500, 660, 0)
+ : PluginClientWindow(plugin, 500, 700, 500, 700, 0)
{
this->plugin = plugin;
}
plugin->load_configuration();
BC_Title *title;
+ add_subwindow(title = new BC_Title(x1, y, _("Mode:")));
+ add_subwindow(mode = new FindObjMode(plugin, this,
+ x1 + 100, y));
+ add_subwindow(reset = new FindObjReset(plugin, this, get_w()-15, y));
+ mode->create_objects();
+ y += mode->get_h() + 10;
+ int y0 = y;
add_subwindow(title = new BC_Title(x1, y, _("Algorithm:")));
add_subwindow(algorithm = new FindObjAlgorithm(plugin, this,
- x1 + title->get_w() + 10, y));
+ x1 + 100, y));
algorithm->create_objects();
- int x0 = get_w() - 15;
- add_subwindow(reset = new FindObjReset(plugin, this, x0, y));
y += algorithm->get_h() + plugin->get_theme()->widget_border;
-
add_subwindow(use_flann = new FindObjUseFlann(plugin, this, x, y));
- x0 -= FindObjMode::calculate_w(this) + 30;
- add_subwindow(mode = new FindObjMode(plugin, this, x0, y));
- mode->create_objects();
- x0 -= BC_Title::calculate_w(this, _("Mode:")) + 10;
- add_subwindow(title = new BC_Title(x0, y, _("Mode:")));
- y += use_flann->get_h() + plugin->get_theme()->widget_border + 10;
+ y += use_flann->get_h() + 10;
- int y1 = y;
+ int y1 = y; y = y0;
+ add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
+ y += replace_object->get_h() + 10;
+ add_subwindow(draw_match = new FindObjDrawMatch(plugin, this, x3, y));
+ y += draw_match->get_h() + 10;
+ add_subwindow(aspect = new FindObjAspect(plugin, this, x3, y));
+ y += aspect->get_h() + 10;
add_subwindow(scale = new FindObjScale(plugin, this, x3, y));
y += scale->get_h() + 10;
add_subwindow(rotate = new FindObjRotate(plugin, this, x3, y));
y += rotate->get_h() + 10;
add_subwindow(translate = new FindObjTranslate(plugin, this, x3, y));
- y += translate->get_h() + 10;
- add_subwindow(replace_object = new FindObjReplace(plugin, this,x3, y));
- x0 = x + 200; y = y1 + 10;
+ int x0 = x + 200; y = y1 + 10;
add_subwindow(title = new BC_Title(x, y, _("Output/scene layer:")));
scene_layer = new FindObjLayer(plugin, this, x0, y,
&plugin->config.scene_layer);
replace_layer->create_objects();
y += replace_layer->get_h() + plugin->get_theme()->widget_border + 10;
+ y += 10;
add_subwindow(title = new BC_Title(x+15, y, _("Units: 0 to 100 percent")));
y += title->get_h();
FindObjConfig &conf = plugin->config;
algorithm->update(conf.algorithm);
use_flann->update(conf.use_flann);
+ draw_match->update(conf.draw_match);
+ aspect->update(conf.aspect);
scale->update(conf.scale);
rotate->update(conf.rotate);
translate->update(conf.translate);
return 1;
}
+FindObjDrawMatch::FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.draw_match, _("Draw match"))
+{
+ this->gui = gui;
+ this->plugin = plugin;
+}
+
+int FindObjDrawMatch::handle_event()
+{
+ plugin->config.draw_match = get_value();
+ plugin->send_configure_change();
+ return 1;
+}
+
+FindObjAspect::FindObjAspect(FindObjMain *plugin, FindObjWindow *gui,
+ int x, int y)
+ : BC_CheckBox(x, y, plugin->config.aspect, _("Aspect"))
+{
+ this->gui = gui;
+ this->plugin = plugin;
+}
+
+int FindObjAspect::handle_event()
+{
+ plugin->config.aspect = get_value();
+ plugin->send_configure_change();
+ return 1;
+}
+
FindObjScale::FindObjScale(FindObjMain *plugin, FindObjWindow *gui,
int x, int y)
: BC_CheckBox(x, y, plugin->config.scale, _("Scale"))
#include "findobj.inc"
#include "guicast.h"
+
class FindObjReset;
class FindObjLayer;
class FindObjScanFloat;
class FindObjScanFloatText;
class FindObjDrawSceneBorder;
-class FindObjDrawKeypoints;
-class FindObjReplace;
class FindObjDrawObjectBorder;
class FindObjDrawReplaceBorder;
-class FindObjDragObject;
+class FindObjDrawKeypoints;
+class FindObjReplace;
class FindObjDragScene;
+class FindObjDragObject;
class FindObjDragReplace;
class FindObjAlgorithm;
-class FindObjMode;
+class FindObjUseFlann;
+class FindObjDrawMatch;
+class FindObjAspect;
class FindObjScale;
class FindObjRotate;
class FindObjTranslate;
+class FindObjMode;
class FindObjBlend;
class FindObjWindow;
FindObjWindow *gui;
};
+class FindObjDrawMatch : public BC_CheckBox
+{
+public:
+ FindObjDrawMatch(FindObjMain *plugin, FindObjWindow *gui, int x, int y);
+ int handle_event();
+ FindObjMain *plugin;
+ FindObjWindow *gui;
+};
+
+class FindObjAspect : public BC_CheckBox
+{
+public:
+ FindObjAspect(FindObjMain *plugin, FindObjWindow *gui, int x, int y);
+ int handle_event();
+ FindObjMain *plugin;
+ FindObjWindow *gui;
+};
+
class FindObjScale : public BC_CheckBox
{
public:
FindObjReset *reset;
FindObjAlgorithm *algorithm;
FindObjUseFlann *use_flann;
+ FindObjDrawMatch *draw_match;
FindObjMode *mode;
+ FindObjAspect *aspect;
FindObjScale *scale;
FindObjRotate *rotate;
FindObjTranslate *translate;
fftw.cfg_params= --disable-fortran --enable-shared=no
ffmpeg.cfg_params= \
--enable-pthreads --enable-gpl \
- --disable-ffserver --disable-ffplay \
- --disable-vaapi \
+ --disable-ffplay --disable-vaapi \
$(call if_pkg,fdk,--enable-libfdk-aac) \
$(call if_pkg,twolame,--enable-libtwolame) \
$(call if_pkg,openjpeg,--enable-libopenjpeg) \
+++ /dev/null
-diff -ru ffmpeg-3.0.orig/libavformat/bluray.c ffmpeg-3.0/libavformat/bluray.c
---- ffmpeg-3.0.orig/libavformat/bluray.c 2015-03-13 11:34:50.000000000 -0600
-+++ ffmpeg-3.0/libavformat/bluray.c 2016-05-09 14:07:34.758713307 -0600
-@@ -28,7 +28,7 @@
- #include "libavutil/opt.h"
-
- #define BLURAY_PROTO_PREFIX "bluray:"
--#define MIN_PLAYLIST_LENGTH 180 /* 3 min */
-+#define MIN_PLAYLIST_LENGTH 0
-
- typedef struct {
- const AVClass *class;
+++ /dev/null
-diff -ur a/libavcodec/libx264.c b/libavcodec/libx264.c
---- a/libavcodec/libx264.c 2018-02-11 17:29:18.000000000 -0700
-+++ b/libavcodec/libx264.c 2018-03-13 09:38:03.241861794 -0600
-@@ -280,7 +280,11 @@
-
- x264_picture_init( &x4->pic );
- x4->pic.img.i_csp = x4->params.i_csp;
-- if (desc->comp[0].depth > 8)
-+#if X264_BUILD >= 153
-+ if (x4->params.i_bitdepth > 8)
-+#else
-+ if (x264_bit_depth > 8)
-+#endif
- x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
- x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt);
-
+++ /dev/null
---- a/libavcodec/libx265.c 2017-12-10 14:35:08.000000000 -0700
-+++ b/libavcodec/libx265.c 2018-02-08 16:57:46.028108824 -0700
-@@ -45,6 +45,7 @@
- int forced_idr;
- char *preset;
- char *tune;
-+ char *profile;
- char *x265_opts;
- } libx265Context;
-
-@@ -114,11 +115,11 @@
- ctx->params->sourceHeight = avctx->height;
- ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
-
-- if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
-+ if ((avctx->color_primaries <= AVCOL_PRI_SMPTE432 &&
- avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
-- (avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
-+ (avctx->color_trc <= AVCOL_TRC_ARIB_STD_B67 &&
- avctx->color_trc != AVCOL_TRC_UNSPECIFIED) ||
-- (avctx->colorspace <= AVCOL_SPC_BT2020_CL &&
-+ (avctx->colorspace <= AVCOL_SPC_ICTCP &&
- avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) {
-
- ctx->params->vui.bEnableVideoSignalTypePresentFlag = 1;
-@@ -220,6 +221,18 @@
- }
- }
-
-+ if (ctx->profile) {
-+ if (ctx->api->param_apply_profile(ctx->params, ctx->profile) < 0) {
-+ int i;
-+ av_log(avctx, AV_LOG_ERROR, "Invalid or incompatible profile set: %s.\n", ctx->profile);
-+ av_log(avctx, AV_LOG_INFO, "Possible profiles:");
-+ for (i = 0; x265_profile_names[i]; i++)
-+ av_log(avctx, AV_LOG_INFO, " %s", x265_profile_names[i]);
-+ av_log(avctx, AV_LOG_INFO, "\n");
-+ return AVERROR(EINVAL);
-+ }
-+ }
-+
- ctx->encoder = ctx->api->encoder_open(ctx->params);
- if (!ctx->encoder) {
- av_log(avctx, AV_LOG_ERROR, "Cannot open libx265 encoder.\n");
-@@ -294,7 +307,7 @@
- for (i = 0; i < nnal; i++)
- payload += nal[i].sizeBytes;
-
-- ret = ff_alloc_packet(pkt, payload);
-+ ret = ff_alloc_packet2(avctx, pkt, payload, payload);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
- return ret;
-@@ -392,6 +412,7 @@
- { "forced-idr", "if forcing keyframes, force them as IDR frames", OFFSET(forced_idr),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
- { "preset", "set the x265 preset", OFFSET(preset), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
- { "tune", "set the x265 tune parameter", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
-+ { "profile", "set the x265 profile", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
- { "x265-params", "set the x265 configuration using a :-separated list of key=value parameters", OFFSET(x265_opts), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
- { NULL }
- };
--- /dev/null
+diff -urN a/libavformat/bluray.c b/libavformat/bluray.c
+--- a/libavformat/bluray.c 2018-04-13 17:34:28.000000000 -0600
++++ b/libavformat/bluray.c 2018-04-24 11:02:19.724232178 -0600
+@@ -28,7 +28,7 @@
+ #include "libavutil/opt.h"
+
+ #define BLURAY_PROTO_PREFIX "bluray:"
+-#define MIN_PLAYLIST_LENGTH 180 /* 3 min */
++#define MIN_PLAYLIST_LENGTH 0
+
+ typedef struct {
+ const AVClass *class;
-diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
---- a/libavformat/mpegtsenc.c 2017-12-10 14:35:10.000000000 -0700
-+++ b/libavformat/mpegtsenc.c 2017-12-18 10:54:14.260167666 -0700
+diff -urN a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+--- a/libavformat/mpegtsenc.c 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/mpegtsenc.c 2018-04-24 10:27:57.193689213 -0600
@@ -56,9 +56,8 @@
int sid; /* service ID */
char *name;
+ ts->delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
+
+ if (ts->m2ts_mode == -1) {
-+ if (av_match_ext(s->filename, "m2ts")) {
++ if (av_match_ext(s->url, "m2ts")) {
+ ts->m2ts_mode = 1;
+ } else {
+ ts->m2ts_mode = 0;
- ts->sdt_packet_period, ts->pat_packet_period);
-
- if (ts->m2ts_mode == -1) {
-- if (av_match_ext(s->filename, "m2ts")) {
+- if (av_match_ext(s->url, "m2ts")) {
- ts->m2ts_mode = 1;
- } else {
- ts->m2ts_mode = 0;
-diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
---- a/libavformat/avformat.h 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/avformat.h 2018-03-13 09:45:00.061310268 -0600
-@@ -504,6 +504,9 @@
+diff -urN a/libavformat/avformat.h b/libavformat/avformat.h
+--- a/libavformat/avformat.h 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/avformat.h 2018-04-24 11:02:20.777232001 -0600
+@@ -487,6 +487,9 @@
The user or muxer can override this through
AVFormatContext.avoid_negative_ts
*/
#define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */
-@@ -664,7 +667,8 @@
+@@ -647,7 +650,8 @@
/**
* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
* AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
*/
int flags;
-diff -ur a/libavformat/dv.c b/ffmpeg-3.4.2/libavformat/dv.c
---- a/libavformat/dv.c 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/dv.c 2018-03-13 09:45:00.061310268 -0600
+diff -urN a/libavformat/dv.c b/libavformat/dv.c
+--- a/libavformat/dv.c 2018-04-13 17:34:28.000000000 -0600
++++ b/libavformat/dv.c 2018-04-24 11:02:20.778232001 -0600
@@ -632,6 +632,7 @@
AVInputFormat ff_dv_demuxer = {
.name = "dv",
.priv_data_size = sizeof(RawDVContext),
.read_probe = dv_probe,
.read_header = dv_read_header,
-diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
---- a/libavformat/matroskadec.c 2018-02-11 17:29:18.000000000 -0700
-+++ b/libavformat/matroskadec.c 2018-03-13 09:45:00.061310268 -0600
-@@ -3992,6 +3992,7 @@
+diff -urN a/libavformat/matroskadec.c b/libavformat/matroskadec.c
+--- a/libavformat/matroskadec.c 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/matroskadec.c 2018-04-24 11:02:20.779232001 -0600
+@@ -4026,6 +4026,7 @@
AVInputFormat ff_matroska_demuxer = {
.name = "matroska,webm",
.long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
.extensions = "mkv,mk3d,mka,mks",
.priv_data_size = sizeof(MatroskaDemuxContext),
.read_probe = matroska_probe,
-@@ -4005,6 +4006,7 @@
+@@ -4039,6 +4040,7 @@
AVInputFormat ff_webm_dash_manifest_demuxer = {
.name = "webm_dash_manifest",
.long_name = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"),
.priv_data_size = sizeof(MatroskaDemuxContext),
.read_header = webm_dash_manifest_read_header,
.read_packet = webm_dash_manifest_read_packet,
-diff -ur a/libavformat/utils.c b/libavformat/utils.c
---- a/libavformat/utils.c 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/utils.c 2018-03-13 09:45:00.062310270 -0600
-@@ -2416,6 +2416,13 @@
+diff -urN a/libavformat/utils.c b/libavformat/utils.c
+--- a/libavformat/utils.c 2018-04-20 04:02:58.000000000 -0600
++++ b/libavformat/utils.c 2018-04-24 11:02:20.780232001 -0600
+@@ -2471,6 +2471,13 @@
return seek_frame_byte(s, stream_index, timestamp, flags);
}
-diff -ru ffmpeg-3.0.orig/libavformat/bluray.c ffmpeg-3.0/libavformat/bluray.c
---- ffmpeg-3.0.orig/libavformat/bluray.c 2015-03-13 11:34:50.000000000 -0600
-+++ ffmpeg-3.0/libavformat/bluray.c 2016-05-09 14:07:34.758713307 -0600
+diff -urN a/libavformat/bluray.c b/libavformat/bluray.c
+--- a/libavformat/bluray.c 2018-04-13 17:34:28.000000000 -0600
++++ b/libavformat/bluray.c 2018-04-24 11:02:19.724232178 -0600
@@ -28,7 +28,7 @@
#include "libavutil/opt.h"
-diff -ur a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
---- a/libavformat/mpegtsenc.c 2017-12-10 14:35:10.000000000 -0700
-+++ b/libavformat/mpegtsenc.c 2017-12-18 10:54:14.260167666 -0700
+diff -urN a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
+--- a/libavformat/mpegtsenc.c 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/mpegtsenc.c 2018-04-24 10:27:57.193689213 -0600
@@ -56,9 +56,8 @@
int sid; /* service ID */
char *name;
+ ts->delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
+
+ if (ts->m2ts_mode == -1) {
-+ if (av_match_ext(s->filename, "m2ts")) {
++ if (av_match_ext(s->url, "m2ts")) {
+ ts->m2ts_mode = 1;
+ } else {
+ ts->m2ts_mode = 0;
- ts->sdt_packet_period, ts->pat_packet_period);
-
- if (ts->m2ts_mode == -1) {
-- if (av_match_ext(s->filename, "m2ts")) {
+- if (av_match_ext(s->url, "m2ts")) {
- ts->m2ts_mode = 1;
- } else {
- ts->m2ts_mode = 0;
-diff -ur a/libavformat/avformat.h b/libavformat/avformat.h
---- a/libavformat/avformat.h 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/avformat.h 2018-03-13 09:45:00.061310268 -0600
-@@ -504,6 +504,9 @@
+diff -urN a/libavformat/avformat.h b/libavformat/avformat.h
+--- a/libavformat/avformat.h 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/avformat.h 2018-04-24 11:02:20.777232001 -0600
+@@ -487,6 +487,9 @@
The user or muxer can override this through
AVFormatContext.avoid_negative_ts
*/
#define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */
-@@ -664,7 +667,8 @@
+@@ -647,7 +650,8 @@
/**
* Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
* AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
*/
int flags;
-diff -ur a/libavformat/dv.c b/ffmpeg-3.4.2/libavformat/dv.c
---- a/libavformat/dv.c 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/dv.c 2018-03-13 09:45:00.061310268 -0600
+diff -urN a/libavformat/dv.c b/libavformat/dv.c
+--- a/libavformat/dv.c 2018-04-13 17:34:28.000000000 -0600
++++ b/libavformat/dv.c 2018-04-24 11:02:20.778232001 -0600
@@ -632,6 +632,7 @@
AVInputFormat ff_dv_demuxer = {
.name = "dv",
.priv_data_size = sizeof(RawDVContext),
.read_probe = dv_probe,
.read_header = dv_read_header,
-diff -ur a/libavformat/matroskadec.c b/libavformat/matroskadec.c
---- a/libavformat/matroskadec.c 2018-02-11 17:29:18.000000000 -0700
-+++ b/libavformat/matroskadec.c 2018-03-13 09:45:00.061310268 -0600
-@@ -3992,6 +3992,7 @@
+diff -urN a/libavformat/matroskadec.c b/libavformat/matroskadec.c
+--- a/libavformat/matroskadec.c 2018-04-20 04:02:57.000000000 -0600
++++ b/libavformat/matroskadec.c 2018-04-24 11:02:20.779232001 -0600
+@@ -4026,6 +4026,7 @@
AVInputFormat ff_matroska_demuxer = {
.name = "matroska,webm",
.long_name = NULL_IF_CONFIG_SMALL("Matroska / WebM"),
.extensions = "mkv,mk3d,mka,mks",
.priv_data_size = sizeof(MatroskaDemuxContext),
.read_probe = matroska_probe,
-@@ -4005,6 +4006,7 @@
+@@ -4039,6 +4040,7 @@
AVInputFormat ff_webm_dash_manifest_demuxer = {
.name = "webm_dash_manifest",
.long_name = NULL_IF_CONFIG_SMALL("WebM DASH Manifest"),
.priv_data_size = sizeof(MatroskaDemuxContext),
.read_header = webm_dash_manifest_read_header,
.read_packet = webm_dash_manifest_read_packet,
-diff -ur a/libavformat/utils.c b/libavformat/utils.c
---- a/libavformat/utils.c 2018-02-11 17:29:06.000000000 -0700
-+++ b/libavformat/utils.c 2018-03-13 09:45:00.062310270 -0600
-@@ -2416,6 +2416,13 @@
+diff -urN a/libavformat/utils.c b/libavformat/utils.c
+--- a/libavformat/utils.c 2018-04-20 04:02:58.000000000 -0600
++++ b/libavformat/utils.c 2018-04-24 11:02:20.780232001 -0600
+@@ -2471,6 +2471,13 @@
return seek_frame_byte(s, stream_index, timestamp, flags);
}