Commit 552c1ff2 authored by Jan Gerber's avatar Jan Gerber
Browse files

make --max_size also understand 640x480, patch by Mikael Nordfeldth

parent 11ab72c2
...@@ -188,7 +188,8 @@ static ff2theora ff2theora_init() { ...@@ -188,7 +188,8 @@ static ff2theora ff2theora_init() {
this->aspect_numerator=0; this->aspect_numerator=0;
this->aspect_denominator=0; this->aspect_denominator=0;
this->frame_aspect=0; this->frame_aspect=0;
this->max_size=-1; this->max_x=-1;
this->max_y=-1;
this->deinterlace=0; // auto by default, if input is flaged as interlaced it will deinterlace. this->deinterlace=0; // auto by default, if input is flaged as interlaced it will deinterlace.
this->soft_target=0; this->soft_target=0;
this->buf_delay=-1; this->buf_delay=-1;
...@@ -703,7 +704,7 @@ void ff2theora_output(ff2theora this) { ...@@ -703,7 +704,7 @@ void ff2theora_output(ff2theora this) {
} }
} }
} }
if (this->max_size > 0) { if (this->max_x > 0) {
int width = display_width-this->frame_leftBand-this->frame_rightBand; int width = display_width-this->frame_leftBand-this->frame_rightBand;
int height = display_height-this->frame_topBand-this->frame_bottomBand; int height = display_height-this->frame_topBand-this->frame_bottomBand;
if (sample_aspect_ratio.den!=0 && sample_aspect_ratio.num!=0) { if (sample_aspect_ratio.den!=0 && sample_aspect_ratio.num!=0) {
...@@ -713,13 +714,13 @@ void ff2theora_output(ff2theora this) { ...@@ -713,13 +714,13 @@ void ff2theora_output(ff2theora this) {
} }
if (this->frame_aspect == 0) if (this->frame_aspect == 0)
this->frame_aspect = (float)width/height; this->frame_aspect = (float)width/height;
if (width > height) { if (width > height && this->max_x/this->frame_aspect <= this->max_y) {
this->picture_width = this->max_size; this->picture_width = this->max_x;
this->picture_height = this->max_size / this->frame_aspect; this->picture_height = this->max_x / this->frame_aspect;
this->picture_height = this->picture_height + this->picture_height%2; this->picture_height = this->picture_height + this->picture_height%2;
} else { } else {
this->picture_height = this->max_size; this->picture_height = this->max_y;
this->picture_width = this->max_size * this->frame_aspect; this->picture_width = this->max_y * this->frame_aspect;
this->picture_width = this->picture_width + this->picture_width%2; this->picture_width = this->picture_width + this->picture_width%2;
} }
} }
...@@ -1788,8 +1789,8 @@ void print_usage() { ...@@ -1788,8 +1789,8 @@ void print_usage() {
" -x, --width scale to given width (in pixels)\n" " -x, --width scale to given width (in pixels)\n"
" -y, --height scale to given height (in pixels)\n" " -y, --height scale to given height (in pixels)\n"
" --max_size scale output frame to be withing box of \n" " --max_size scale output frame to be within box of \n"
" given size (in pixels)\n" " given size, height optional (%%d[x%%d], i.e. 640x480)\n"
" --aspect define frame aspect ratio: i.e. 4:3 or 16:9\n" " --aspect define frame aspect ratio: i.e. 4:3 or 16:9\n"
" -F, --framerate output framerate e.g 25:2 or 16\n" " -F, --framerate output framerate e.g 25:2 or 16\n"
" --croptop, --cropbottom, --cropleft, --cropright\n" " --croptop, --cropbottom, --cropleft, --cropright\n"
...@@ -2121,7 +2122,9 @@ int main(int argc, char **argv) { ...@@ -2121,7 +2122,9 @@ int main(int argc, char **argv) {
flag = -1; flag = -1;
break; break;
case MAXSIZE_FLAG: case MAXSIZE_FLAG:
convert->max_size = atoi(optarg); if(sscanf(optarg, "%dx%d", &convert->max_x, &convert->max_y) != 2) {
convert->max_y = convert->max_x = atoi(optarg);
}
flag = -1; flag = -1;
break; break;
case INPUTFPS_FLAG: case INPUTFPS_FLAG:
......
...@@ -58,7 +58,8 @@ typedef struct ff2theora{ ...@@ -58,7 +58,8 @@ typedef struct ff2theora{
ogg_int32_t aspect_numerator; ogg_int32_t aspect_numerator;
ogg_int32_t aspect_denominator; ogg_int32_t aspect_denominator;
double frame_aspect; double frame_aspect;
int max_size; int max_x;
int max_y;
int pix_fmt; int pix_fmt;
int video_quality; int video_quality;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment