X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Fbdwrite.C;h=93b656904734ab4080980bc40a90b15b6c03f9a6;hb=e3c81d537528ce9e4300d54fc5c89e20c21070a0;hp=3ac4b0ff503700947c29f116a4c2391e747a9536;hpb=91efd376233a15f6572e6f68d28a5bee69797e87;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/bdwrite.C b/cinelerra-5.0/cinelerra/bdwrite.C index 3ac4b0ff..93b65690 100644 --- a/cinelerra-5.0/cinelerra/bdwrite.C +++ b/cinelerra-5.0/cinelerra/bdwrite.C @@ -41,6 +41,13 @@ #include #include #include +// work arounds (centos) +#ifndef INT64_MAX +#define INT64_MAX 9223372036854775807LL +#endif +#ifndef INT64_MIN +#define INT64_MIN (-INT64_MAX-1) +#endif #include "arraylist.h" #include "cstrdup.h" @@ -719,7 +726,9 @@ public: int write(); mpls_pi() {} - ~mpls_pi() {} + ~mpls_pi() { + clip.remove_all_objects(); + } }; class _mpls_plm { @@ -1168,7 +1177,10 @@ public: strcpy(filename, fn); brk = 0; pidx = 0; pgm_pid = -1; still = 0; } - ~media_info() { streams.remove_all_objects(); } + ~media_info() { + streams.remove_all_objects(); + programs.remove_all_objects(); + } int scan(); int scan(AVFormatContext *fmt_ctx); @@ -2436,12 +2448,13 @@ static int bd_video_rate(double rate) exit(1); } -static int bd_aspect_ratio(int w, double ratio) +static int bd_aspect_ratio(int w, int h, double ratio) { - if( fabs(ratio-1.333) < 0.01 ) return BLURAY_ASPECT_RATIO_4_3; - if( fabs(ratio-1.777) < 0.01 ) return BLURAY_ASPECT_RATIO_16_9; + double aspect = (w * ratio) / h; + if( fabs(aspect-1.333) < 0.01 ) return BLURAY_ASPECT_RATIO_4_3; + if( fabs(aspect-1.777) < 0.01 ) return BLURAY_ASPECT_RATIO_16_9; return w == 720 ? BLURAY_ASPECT_RATIO_4_3 : BLURAY_ASPECT_RATIO_16_9; - fprintf(stderr, "unknown bluray aspect ratio %5.3f\n",ratio); + fprintf(stderr, "unknown bluray aspect ratio %5.3f\n",aspect); exit(1); } @@ -2458,13 +2471,10 @@ int media_info::scan() av_dict_set(&fopts, "threads", "auto", 0); int ret = avformat_open_input(&fmt_ctx, filename, NULL, &fopts); av_dict_free(&fopts); + if( ret < 0 ) return ret; + ret = avformat_find_stream_info(fmt_ctx, NULL); - if( ret >= 0 ) - ret = avformat_find_stream_info(fmt_ctx, NULL); - - if( ret >= 0 ) { - bit_rate = fmt_ctx->bit_rate; - } + bit_rate = fmt_ctx->bit_rate; int ep_pid = -1; for( int i=0; ret>=0 && i<(int)fmt_ctx->nb_streams; ++i ) { @@ -2486,8 +2496,9 @@ int media_info::scan() st->codec->flags & CODEC_FLAG_INTERLACED_ME); s->rate = bd_video_rate(!st->codec->framerate.den ? 0 : (double)st->codec->framerate.num / st->codec->framerate.den); - s->aspect = bd_aspect_ratio(st->codec->width,!st->sample_aspect_ratio.den ? 0 : - (double)st->sample_aspect_ratio.num / st->sample_aspect_ratio.den); + s->aspect = bd_aspect_ratio(st->codec->width, st->codec->height, + !st->sample_aspect_ratio.num || !st->sample_aspect_ratio.den ? 1. : + (double)st->sample_aspect_ratio.num / st->sample_aspect_ratio.den); break; } case AVMEDIA_TYPE_AUDIO: { s->coding_type = bd_stream_type(codec_id); @@ -2519,8 +2530,22 @@ int media_info::scan() pgm->ep_pid = ep_pid; pgm->pmt_pid = 0x1000; pgm->pcr_pid = 0x100; - for( int jj=0; jjduration = 0; + for( int jj=0; jjstreams[jj]; + AVMediaType type = st->codec->codec_type; + switch( type ) { + case AVMEDIA_TYPE_VIDEO: + case AVMEDIA_TYPE_AUDIO: + break; + default: + continue; + } pgm->strm_idx.append(jj); + if( pgm->duration < st->duration ) + pgm->duration = av_rescale_q(st->duration, st->time_base, clk45k); + } + programs.append(pgm); } for( int ii=0; ii= 0 ) ret = scan(fmt_ctx); - if( fmt_ctx ) - avformat_close_input(&fmt_ctx); + for( int i=0; i<(int)fmt_ctx->nb_streams; ++i ) + avcodec_close(fmt_ctx->streams[i]->codec); + avformat_close_input(&fmt_ctx); return ret; }