Remove -crop* options.

Users are required to use the libavfilter crop filter.

Originally committed as revision 25518 to svn://svn.ffmpeg.org/ffmpeg/trunk
oldabi
Stefano Sabatini 14 years ago
parent f2f8fb1035
commit 5879ea6d27
  1. 1
      Changelog
  2. 15
      doc/ffmpeg-doc.texi
  3. 175
      ffmpeg.c

@ -46,6 +46,7 @@ version <next>:
- RTP depacketization of the X-QT QuickTime format
- SAP (Session Announcement Protocol, RFC 2974) muxer and demuxer
- cropdetect filter
- ffmpeg -crop* options removed
version 0.6:

@ -226,14 +226,13 @@ The following abbreviations are recognized:
@item -aspect @var{aspect}
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
@item -croptop @var{size} (deprecated - use the crop filter instead)
Set top crop band size (in pixels).
@item -cropbottom @var{size} (deprecated - use the crop filter instead)
Set bottom crop band size (in pixels).
@item -cropleft @var{size} (deprecated - use the crop filter instead)
Set left crop band size (in pixels).
@item -cropright @var{size} (deprecated - use the crop filter instead)
Set right crop band size (in pixels).
@item -croptop @var{size}
@item -cropbottom @var{size}
@item -cropleft @var{size}
@item -cropright @var{size}
All the crop options have been removed. Use -vf
crop=width:height:x:y instead.
@item -padtop @var{size}
@item -padbottom @var{size}
@item -padleft @var{size}

@ -136,10 +136,6 @@ static int frame_height = 0;
static float frame_aspect_ratio = 0;
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
static enum SampleFormat audio_sample_fmt = SAMPLE_FMT_NONE;
static int frame_topBand = 0;
static int frame_bottomBand = 0;
static int frame_leftBand = 0;
static int frame_rightBand = 0;
static int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX};
static AVRational frame_rate;
static float video_qscale = 0;
@ -276,19 +272,6 @@ typedef struct AVOutputStream {
int original_height;
int original_width;
/* cropping area sizes */
int video_crop;
int topBand;
int bottomBand;
int leftBand;
int rightBand;
/* cropping area of first frame */
int original_topBand;
int original_bottomBand;
int original_leftBand;
int original_rightBand;
/* audio only */
int audio_resample;
ReSampleContext *resample; /* for audio resampling */
@ -395,23 +378,7 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
last_filter = ist->input_video_filter;
if (ost->video_crop) {
snprintf(args, 255, "%d:%d:%d:%d",
codec->width, codec->height,
ost->leftBand, ost->topBand);
if ((ret = avfilter_open(&filter, avfilter_get_by_name("crop"), NULL)) < 0)
return ret;
if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
return ret;
last_filter = filter;
avfilter_graph_add_filter(graph, last_filter);
}
if((codec->width !=
icodec->width - (frame_leftBand + frame_rightBand)) ||
(codec->height != icodec->height - (frame_topBand + frame_bottomBand))) {
if (codec->width != icodec->width || codec->height != icodec->height) {
snprintf(args, 255, "%d:%d:flags=0x%X",
codec->width,
codec->height,
@ -1113,9 +1080,6 @@ static void do_video_out(AVFormatContext *s,
int *frame_size)
{
int nb_frames, i, ret;
#if !CONFIG_AVFILTER
int64_t topBand, bottomBand, leftBand, rightBand;
#endif
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec;
@ -1163,28 +1127,13 @@ static void do_video_out(AVFormatContext *s,
if (nb_frames <= 0)
return;
#if CONFIG_AVFILTER
formatted_picture = in_picture;
#else
if (ost->video_crop) {
if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
fprintf(stderr, "error cropping picture\n");
if (exit_on_error)
ffmpeg_exit(1);
return;
}
formatted_picture = &picture_crop_temp;
} else {
formatted_picture = in_picture;
}
#endif
final_picture = formatted_picture;
padding_src = formatted_picture;
resampling_dst = &ost->pict_tmp;
if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
if ( ost->resample_height != ist->st->codec->height
|| ost->resample_width != ist->st->codec->width
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
@ -1196,37 +1145,16 @@ static void do_video_out(AVFormatContext *s,
if (ost->video_resample) {
padding_src = NULL;
final_picture = &ost->pict_tmp;
if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
if( ost->resample_height != ist->st->codec->height
|| ost->resample_width != ist->st->codec->width
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
/* keep bands proportional to the frame size */
topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
/* sanity check to ensure no bad band sizes sneak in */
av_assert0(topBand <= INT_MAX && topBand >= 0);
av_assert0(bottomBand <= INT_MAX && bottomBand >= 0);
av_assert0(leftBand <= INT_MAX && leftBand >= 0);
av_assert0(rightBand <= INT_MAX && rightBand >= 0);
ost->topBand = topBand;
ost->bottomBand = bottomBand;
ost->leftBand = leftBand;
ost->rightBand = rightBand;
ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
ost->resample_pix_fmt= ist->st->codec->pix_fmt;
/* initialize a new scaler context */
sws_freeContext(ost->img_resample_ctx);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
ist->st->codec->width - (ost->leftBand + ost->rightBand),
ist->st->codec->height - (ost->topBand + ost->bottomBand),
ist->st->codec->width,
ist->st->codec->height,
ist->st->codec->pix_fmt,
ost->st->codec->width,
ost->st->codec->height,
@ -2209,18 +2137,9 @@ static int transcode(AVFormatContext **output_files,
fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n");
ffmpeg_exit(1);
}
ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0);
ost->video_resample = ((codec->width != icodec->width -
(frame_leftBand + frame_rightBand)) ||
(codec->height != icodec->height -
(frame_topBand + frame_bottomBand)) ||
ost->video_resample = (codec->width != icodec->width ||
codec->height != icodec->height ||
(codec->pix_fmt != icodec->pix_fmt));
if (ost->video_crop) {
ost->topBand = ost->original_topBand = frame_topBand;
ost->bottomBand = ost->original_bottomBand = frame_bottomBand;
ost->leftBand = ost->original_leftBand = frame_leftBand;
ost->rightBand = ost->original_rightBand = frame_rightBand;
}
if (ost->video_resample) {
avcodec_get_frame_defaults(&ost->pict_tmp);
if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
@ -2230,8 +2149,8 @@ static int transcode(AVFormatContext **output_files,
}
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
ost->img_resample_ctx = sws_getContext(
icodec->width - (frame_leftBand + frame_rightBand),
icodec->height - (frame_topBand + frame_bottomBand),
icodec->width,
icodec->height,
icodec->pix_fmt,
codec->width,
codec->height,
@ -2248,8 +2167,8 @@ static int transcode(AVFormatContext **output_files,
#endif
codec->bits_per_raw_sample= 0;
}
ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand);
ost->resample_width = icodec->width - (frame_leftBand + frame_rightBand);
ost->resample_height = icodec->height;
ost->resample_width = icodec->width;
ost->resample_pix_fmt= icodec->pix_fmt;
ost->encoding_needed = 1;
ist->decoding_needed = 1;
@ -2744,64 +2663,10 @@ static int opt_bitrate(const char *opt, const char *arg)
return 0;
}
static void opt_frame_crop_top(const char *arg)
{
frame_topBand = atoi(arg);
if (frame_topBand < 0) {
fprintf(stderr, "Incorrect top crop size\n");
ffmpeg_exit(1);
}
if ((frame_topBand) >= frame_height){
fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
ffmpeg_exit(1);
}
fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
frame_height -= frame_topBand;
}
static void opt_frame_crop_bottom(const char *arg)
{
frame_bottomBand = atoi(arg);
if (frame_bottomBand < 0) {
fprintf(stderr, "Incorrect bottom crop size\n");
ffmpeg_exit(1);
}
if ((frame_bottomBand) >= frame_height){
fprintf(stderr, "Vertical crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
ffmpeg_exit(1);
}
fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
frame_height -= frame_bottomBand;
}
static void opt_frame_crop_left(const char *arg)
static int opt_frame_crop(const char *opt, const char *arg)
{
frame_leftBand = atoi(arg);
if (frame_leftBand < 0) {
fprintf(stderr, "Incorrect left crop size\n");
ffmpeg_exit(1);
}
if ((frame_leftBand) >= frame_width){
fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
ffmpeg_exit(1);
}
fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
frame_width -= frame_leftBand;
}
static void opt_frame_crop_right(const char *arg)
{
frame_rightBand = atoi(arg);
if (frame_rightBand < 0) {
fprintf(stderr, "Incorrect right crop size\n");
ffmpeg_exit(1);
}
if ((frame_rightBand) >= frame_width){
fprintf(stderr, "Horizontal crop dimensions are outside the range of the original image.\nRemember to crop first and scale second.\n");
ffmpeg_exit(1);
}
fprintf(stderr, "-crop* is deprecated in favor of the crop avfilter\n");
frame_width -= frame_rightBand;
fprintf(stderr, "Option '%s' has been removed, use the crop filter instead\n", opt);
return AVERROR(EINVAL);
}
static void opt_frame_size(const char *arg)
@ -4211,10 +4076,10 @@ static const OptionDef options[] = {
{ "s", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_size}, "set frame size (WxH or abbreviation)", "size" },
{ "aspect", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_aspect_ratio}, "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
{ "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_frame_pix_fmt}, "set pixel format, 'list' as argument shows all the pixel formats supported", "format" },
{ "croptop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_top}, "Deprecated, please use the crop avfilter", "size" },
{ "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "Deprecated, please use the crop avfilter", "size" },
{ "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "Deprecated, please use the crop avfilter", "size" },
{ "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "Deprecated, please use the crop avfilter", "size" },
{ "croptop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Deprecated, please use the crop avfilter", "size" },
{ "cropbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
{ "cropleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
{ "cropright", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop}, "Removed, please use the crop avfilter", "size" },
{ "padtop", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
{ "padbottom", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },
{ "padleft", OPT_FUNC2 | HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "Removed, use the pad filter instead", "size" },

Loading…
Cancel
Save