projects
/
goodguy
/
history.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
upgrade to ffmpeg-2.8
[goodguy/history.git]
/
cinelerra-5.0
/
cinelerra
/
ffmpeg.C
diff --git
a/cinelerra-5.0/cinelerra/ffmpeg.C
b/cinelerra-5.0/cinelerra/ffmpeg.C
index 92a9580210d4cf07b6ad23fbc418db1b43e2909d..2f1a1987cf6cd7fe6397da5ccb43381d4b82827d 100644
(file)
--- a/
cinelerra-5.0/cinelerra/ffmpeg.C
+++ b/
cinelerra-5.0/cinelerra/ffmpeg.C
@@
-18,6
+18,8
@@
#include "fileffmpeg.h"
#include "file.h"
#include "ffmpeg.h"
#include "fileffmpeg.h"
#include "file.h"
#include "ffmpeg.h"
+#include "libdv.h"
+#include "libmjpeg.h"
#include "mainerror.h"
#include "mwindow.h"
#include "vframe.h"
#include "mainerror.h"
#include "mwindow.h"
#include "vframe.h"
@@
-982,13
+984,15
@@
AVRational FFMPEG::check_frame_rate(AVCodec *codec, double frame_rate)
return max_err < 0.0001 ? best_rate : (AVRational) { 0, 0 };
}
return max_err < 0.0001 ? best_rate : (AVRational) { 0, 0 };
}
-AVRational FFMPEG::to_sample_aspect_ratio(
double aspect_ratio
)
+AVRational FFMPEG::to_sample_aspect_ratio(
Asset *asset
)
{
#if 1
{
#if 1
- int height = 1000000, width = height * aspect_ratio;
+ double display_aspect = asset->width / (double)asset->height;
+ double sample_aspect = asset->aspect_ratio / display_aspect;
+ int width = 1000000, height = width * sample_aspect + 0.5;
float w, h;
MWindow::create_aspect_ratio(w, h, width, height);
float w, h;
MWindow::create_aspect_ratio(w, h, width, height);
- return (AVRational){(int)
w, (int)h
};
+ return (AVRational){(int)
h, (int)w
};
#else
// square pixels
return (AVRational){1, 1};
#else
// square pixels
return (AVRational){1, 1};
@@
-1335,7
+1339,13
@@
int FFMPEG::open_decoder()
AVStream *st = fmt_ctx->streams[i];
if( st->duration == AV_NOPTS_VALUE ) bad_time = 1;
AVCodecContext *avctx = st->codec;
AVStream *st = fmt_ctx->streams[i];
if( st->duration == AV_NOPTS_VALUE ) bad_time = 1;
AVCodecContext *avctx = st->codec;
+ const AVCodecDescriptor *codec_desc = avcodec_descriptor_get(avctx->codec_id);
+ if( !codec_desc ) continue;
if( avctx->codec_type == AVMEDIA_TYPE_VIDEO ) {
if( avctx->codec_type == AVMEDIA_TYPE_VIDEO ) {
+ if( avctx->width < 1 ) continue;
+ if( avctx->height < 1 ) continue;
+ AVRational framerate = av_guess_frame_rate(fmt_ctx, st, 0);
+ if( framerate.num < 1 ) continue;
has_video = 1;
FFVideoStream *vid = new FFVideoStream(this, st, i);
int vidx = ffvideo.size();
has_video = 1;
FFVideoStream *vid = new FFVideoStream(this, st, i);
int vidx = ffvideo.size();
@@
-1343,7
+1353,6
@@
int FFMPEG::open_decoder()
ffvideo.append(vid);
vid->width = avctx->width;
vid->height = avctx->height;
ffvideo.append(vid);
vid->width = avctx->width;
vid->height = avctx->height;
- AVRational framerate = av_guess_frame_rate(fmt_ctx, st, 0);
vid->frame_rate = !framerate.den ? 0 : (double)framerate.num / framerate.den;
double secs = to_secs(st->duration, st->time_base);
vid->length = secs * vid->frame_rate;
vid->frame_rate = !framerate.den ? 0 : (double)framerate.num / framerate.den;
double secs = to_secs(st->duration, st->time_base);
vid->length = secs * vid->frame_rate;
@@
-1354,6
+1363,8
@@
int FFMPEG::open_decoder()
vid->create_filter(opt_video_filter, avctx,avctx);
}
else if( avctx->codec_type == AVMEDIA_TYPE_AUDIO ) {
vid->create_filter(opt_video_filter, avctx,avctx);
}
else if( avctx->codec_type == AVMEDIA_TYPE_AUDIO ) {
+ if( avctx->channels < 1 ) continue;
+ if( avctx->sample_rate < 1 ) continue;
has_audio = 1;
FFAudioStream *aud = new FFAudioStream(this, st, i);
int aidx = ffaudio.size();
has_audio = 1;
FFAudioStream *aud = new FFAudioStream(this, st, i);
int aidx = ffaudio.size();
@@
-1440,6
+1451,10
@@
int FFMPEG::open_encoder(const char *type, const char *spec)
return 1;
}
return 1;
}
+ if( !strcmp(codec_name, CODEC_TAG_DVSD) ) strcpy(codec_name, "dv");
+ else if( !strcmp(codec_name, CODEC_TAG_MJPEG) ) strcpy(codec_name, "mjpeg");
+ else if( !strcmp(codec_name, CODEC_TAG_JPEG) ) strcpy(codec_name, "jpeg");
+
int ret = 0;
ff_lock("FFMPEG::open_encoder");
FFStream *fst = 0;
int ret = 0;
ff_lock("FFMPEG::open_encoder");
FFStream *fst = 0;
@@
-1560,7
+1575,7
@@
int FFMPEG::open_encoder(const char *type, const char *spec)
vid->height = asset->height;
ctx->height = (vid->height+3) & ~3;
vid->frame_rate = asset->frame_rate;
vid->height = asset->height;
ctx->height = (vid->height+3) & ~3;
vid->frame_rate = asset->frame_rate;
- ctx->sample_aspect_ratio = to_sample_aspect_ratio(asset
->aspect_ratio
);
+ ctx->sample_aspect_ratio = to_sample_aspect_ratio(asset);
ctx->pix_fmt = codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV420P;
AVRational frame_rate = check_frame_rate(codec, vid->frame_rate);
if( !frame_rate.num || !frame_rate.den ) {
ctx->pix_fmt = codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV420P;
AVRational frame_rate = check_frame_rate(codec, vid->frame_rate);
if( !frame_rate.num || !frame_rate.den ) {