[xiph-commits] r15536 - in trunk/ffmpeg2theora: . src
j at svn.xiph.org
j at svn.xiph.org
Wed Nov 26 05:53:56 PST 2008
Author: j
Date: 2008-11-26 05:53:56 -0800 (Wed, 26 Nov 2008)
New Revision: 15536
Modified:
trunk/ffmpeg2theora/
trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
* add new option --no-upscaling to give max width, height and/or samplerate/channels without encoding at higher values than input
* fix crop
Property changes on: trunk/ffmpeg2theora
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2008-11-22 16:06:42.303999901 +0100
committer: j
properties:
branch-nick: ffmpeg2theora
+ timestamp: 2008-11-26 14:52:01.926000118 +0100
committer: j
properties:
branch-nick: ffmpeg2theora
Name: bzr:file-ids
- src/ffmpeg2theora.c 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c
src/ffmpeg2theora.h ffmpeg2theora.h-20080523174200-q6z54q34pgkgpz50-1
src/theorautils.c 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:theorautils.c
src/theorautils.h 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:theorautils.h
+ src/ffmpeg2theora.c 6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c
Name: bzr:text-parents
- src/theorautils.c j-20080921104137-otk3xx827h5cofwl
src/theorautils.h j-20080921104137-otk3xx827h5cofwl
+
Name: bzr:revision-id:v3-single1-dHJ1bmsvZmZtcGVnMnRoZW9yYQ..
- 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
225 j-20080901112127-tyeax385hwukjt13
226 j-20080915075112-fg3yc8radbplosnc
227 j-20080921103515-w89p8jqwt3oq5u20
228 j-20080921103703-prnl3ls2f6u4g177
229 j-20080921104137-otk3xx827h5cofwl
230 j-20080921104242-dswny7jm93stokej
231 j-20081001102101-rl2rf1x9u8e5zrqk
232 j-20081001103246-0uwni13nt5b2mqyw
233 j-20081001104039-68e6rbv58e743plv
234 j-20081001111423-31lxb69fs7023eqi
235 j-20081001112345-eo9e3eheszd68pkb
236 j-20081002180939-vwdafec5iu2ihyq6
237 j-20081003143408-49wdpdkvhnf719rq
238 j-20081003153911-nh2fzqikxgbm7tuk
239 j-20081006092929-7kh3399r2tkat0x8
240 j-20081006120928-dqhlormykse02wss
241 j-20081010131634-o5sswtynyozb0dmb
242 j-20081010134449-4i1ak9vg1yv4ix53
243 j-20081010154655-55t7kuwhmo8964ya
244 j-20081010171055-w0wdhrrxucgdpvn1
245 j-20081016143100-chii7fl38ao2h6rd
246 j-20081105200328-iez493l5o7o333ae
247 j-20081105202607-3vjd88uf5rgna3pi
248 j-20081105204931-zah2kekajc2u9czu
249 j-20081110173803-i116mo4960rnmsqt
250 j-20081110173921-b79zigtpvfvowzd6
251 j-20081122150642-x51oi8he4clq62kw
+ 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw
203 j-20080526111321-nhzaqh6ivzn0vs7b
204 j-20080527100851-2v5eyxxrq1riqi50
205 j-20080527101341-9ynbgth2b15jw792
206 j-20080527205556-19tffvfrxgt3khld
207 j-20080527205840-zeestdde3v1zks9k
208 j-20080527210129-e73y56uwmzbcid00
209 j-20080527211813-5ll680ed1q4byp16
210 j-20080528102006-aeippim0tn70mz3f
211 j-20080528104907-40kiidjojvta8j61
212 j-20080528111329-vkqbt7xkat2o9h4z
213 j-20080529102940-q9xdwm5v9espzomv
214 j-20080529111405-nmh99aon1kmh22qm
215 j-20080530094948-ncq064s4uggd9z95
216 j-20080530095056-hko2vjfwipikwjyu
217 j-20080530171822-bab8sy8lpotf8081
218 j-20080603170442-v0pxspvfcucvsaex
219 j-20080617110355-xwbeg1xidmv8fubp
220 j-20080617110518-khqlhaan52kz3lii
221 j-20080723194934-63m20dc3zmkhwj4o
222 j-20080724140108-ntgbrk6913nvtk4b
223 j-20080802221321-3fcp0s6rehryx0n5
224 j-20080802221340-0s6mh8llk6nyon5d
225 j-20080901112127-tyeax385hwukjt13
226 j-20080915075112-fg3yc8radbplosnc
227 j-20080921103515-w89p8jqwt3oq5u20
228 j-20080921103703-prnl3ls2f6u4g177
229 j-20080921104137-otk3xx827h5cofwl
230 j-20080921104242-dswny7jm93stokej
231 j-20081001102101-rl2rf1x9u8e5zrqk
232 j-20081001103246-0uwni13nt5b2mqyw
233 j-20081001104039-68e6rbv58e743plv
234 j-20081001111423-31lxb69fs7023eqi
235 j-20081001112345-eo9e3eheszd68pkb
236 j-20081002180939-vwdafec5iu2ihyq6
237 j-20081003143408-49wdpdkvhnf719rq
238 j-20081003153911-nh2fzqikxgbm7tuk
239 j-20081006092929-7kh3399r2tkat0x8
240 j-20081006120928-dqhlormykse02wss
241 j-20081010131634-o5sswtynyozb0dmb
242 j-20081010134449-4i1ak9vg1yv4ix53
243 j-20081010154655-55t7kuwhmo8964ya
244 j-20081010171055-w0wdhrrxucgdpvn1
245 j-20081016143100-chii7fl38ao2h6rd
246 j-20081105200328-iez493l5o7o333ae
247 j-20081105202607-3vjd88uf5rgna3pi
248 j-20081105204931-zah2kekajc2u9czu
249 j-20081110173803-i116mo4960rnmsqt
250 j-20081110173921-b79zigtpvfvowzd6
251 j-20081122150642-x51oi8he4clq62kw
252 j-20081126135201-8y0orpwbdzn0doai
Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c 2008-11-26 13:53:39 UTC (rev 15535)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c 2008-11-26 13:53:56 UTC (rev 15536)
@@ -54,6 +54,7 @@
SYNC_FLAG,
NOAUDIO_FLAG,
NOVIDEO_FLAG,
+ NOUPSCALING_FLAG,
CROPTOP_FLAG,
CROPBOTTOM_FLAG,
CROPRIGHT_FLAG,
@@ -144,6 +145,7 @@
if (this != NULL){
this->disable_audio=0;
this->disable_video=0;
+ this->no_upscaling=0;
this->video_index = -1;
this->audio_index = -1;
this->start_time=0;
@@ -360,6 +362,17 @@
this->picture_width = this->picture_width - this->picture_width%2;
}
+ if(this->no_upscaling) {
+ if(this->picture_width && this->picture_width > venc->width) {
+ this->picture_width = venc->width;
+ this->picture_height = venc->height;
+ }
+ if(this->fps < (double)this->framerate_new.num / this->framerate_new.den) {
+ this->framerate_new.num = vstream->r_frame_rate.num;
+ this->framerate_new.den = vstream->r_frame_rate.den;
+ }
+ }
+
if(this->preset == V2V_PRESET_PREVIEW){
if(abs(this->fps-30)<1 && (venc->width!=NTSC_HALF_WIDTH || venc->height!=NTSC_HALF_HEIGHT) ){
this->picture_width=NTSC_HALF_WIDTH;
@@ -559,15 +572,15 @@
sws_flags, NULL, NULL, NULL
);
this->sws_scale_ctx = sws_getContext(
- venc->width - (this->frame_leftBand + this->frame_rightBand),
- venc->height - (this->frame_topBand + this->frame_bottomBand),
+ venc->width - (this->frame_leftBand + this->frame_rightBand),
+ venc->height - (this->frame_topBand + this->frame_bottomBand),
this->pix_fmt,
this->frame_width, this->frame_height, this->pix_fmt,
sws_flags, NULL, NULL, NULL
);
fprintf(stderr, " Resize: %dx%d",venc->width,venc->height);
if(this->frame_topBand || this->frame_bottomBand ||
- this->frame_leftBand || this->frame_rightBand){
+ this->frame_leftBand || this->frame_rightBand){
fprintf(stderr, " => %dx%d",
venc->width-this->frame_leftBand-this->frame_rightBand,
venc->height-this->frame_topBand-this->frame_bottomBand);
@@ -600,6 +613,13 @@
if (this->channels != aenc->channels && aenc->codec_id == CODEC_ID_AC3)
aenc->channels = this->channels;
+ if(this->no_upscaling) {
+ if(this->sample_rate > aenc->sample_rate)
+ this->sample_rate = aenc->sample_rate;
+ if(this->channels > aenc->channels)
+ this->channels = aenc->channels;
+ }
+
if (acodec != NULL && avcodec_open (aenc, acodec) >= 0){
if(this->sample_rate != aenc->sample_rate || this->channels != aenc->channels){
this->audio_resample_ctx = audio_resample_init (this->channels,aenc->channels,this->sample_rate,aenc->sample_rate);
@@ -628,6 +648,9 @@
AVFrame *output_resized=NULL;
AVFrame *output_buffered_p=NULL;
AVFrame *output_buffered=NULL;
+ AVFrame *output_cropped_p=NULL;
+ AVFrame *output_cropped=NULL;
+
AVPacket pkt;
int len;
@@ -660,11 +683,14 @@
frame_p = frame = frame_alloc(vstream->codec->pix_fmt,
vstream->codec->width,vstream->codec->height);
output_tmp_p = output_tmp = frame_alloc(this->pix_fmt,
- vstream->codec->width,vstream->codec->height);
+ vstream->codec->width, vstream->codec->height);
output_p = output = frame_alloc(this->pix_fmt,
vstream->codec->width,vstream->codec->height);
output_resized_p = output_resized = frame_alloc(this->pix_fmt,
this->frame_width, this->frame_height);
+ output_cropped_p = output_cropped = frame_alloc(this->pix_fmt,
+ vstream->codec->width-this->frame_leftBand,
+ vstream->codec->height-this->frame_topBand);
output_buffered_p = output_buffered = frame_alloc(this->pix_fmt,
this->frame_width, this->frame_height);
@@ -885,24 +911,27 @@
ppMode, ppContext, this->pix_fmt);
#ifdef HAVE_FRAMEHOOK
if(this->vhook)
- frame_hook_process((AVPicture *)output, this->pix_fmt, venc->width,venc->height, 0);
+ frame_hook_process((AVPicture *)output, this->pix_fmt, venc->width,venc->height, 0);
#endif
+
if (this->frame_topBand || this->frame_leftBand) {
- if (av_picture_crop((AVPicture *)output_tmp, (AVPicture *)output,
- this->pix_fmt, this->frame_topBand, this->frame_leftBand) < 0) {
- av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
- }
- av_picture_copy((AVPicture *)output, (AVPicture *)output_tmp, this->pix_fmt,
- venc->width, venc->height);
+ if (av_picture_crop((AVPicture *)output_cropped,
+ (AVPicture *)output, his->pix_fmt,
+ this->frame_topBand, this->frame_leftBand) < 0) {
+ av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
+ }
+ output_cropped_p = NULL;
+ } else {
+ output_cropped = output;
}
if(this->sws_scale_ctx){
sws_scale(this->sws_scale_ctx,
- output->data, output->linesize, 0, venc->height - (this->frame_topBand + this->frame_bottomBand),
+ output_cropped->data, output_cropped->linesize, 0,
+ venc->height - (this->frame_topBand + this->frame_bottomBand),
output_resized->data, output_resized->linesize);
}
else{
- av_picture_copy((AVPicture *)output_resized, (AVPicture *)output, this->pix_fmt,
- venc->width, venc->height);
+ output_resized = output_cropped;
}
}
@@ -1021,6 +1050,7 @@
frame_dealloc(output_tmp_p);
frame_dealloc(output_resized_p);
frame_dealloc(output_buffered_p);
+ frame_dealloc(output_cropped_p);
}
av_free(audio_buf);
av_free(resampled);
@@ -1191,6 +1221,8 @@
" -S, --sharpness [0 to 2] sharpness of images (default: 0).\n"
" Note: lower values make the video sharper.\n"
" -K, --keyint [1 to 65536] keyframe interval (default: 64)\n"
+ " --no-upscaling only scale video or resample audio if input is\n"
+ " bigger than provided parameters\n"
"\n"
"Video transfer options:\n"
" --pp Video Postprocessing, denoise, deblock, deinterlacer\n"
@@ -1322,6 +1354,7 @@
{"nosound",0,&flag,NOAUDIO_FLAG},
{"noaudio",0,&flag,NOAUDIO_FLAG},
{"novideo",0,&flag,NOVIDEO_FLAG},
+ {"no-upscaling",0,&flag,NOUPSCALING_FLAG},
#ifdef HAVE_FRAMEHOOK
{"vhook",required_argument,&flag,VHOOK_FLAG},
#endif
@@ -1414,6 +1447,10 @@
convert->disable_video = 1;
flag = -1;
break;
+ case NOUPSCALING_FLAG:
+ convert->no_upscaling = 1;
+ flag = -1;
+ break;
case OPTIMIZE_FLAG:
info.speed_level = 0;
flag = -1;
More information about the commits
mailing list