On Sun, 25 Dec 2011 01:49:37 +0530, Aneesh Dogra <[email protected]> wrote:
> ---
> avplay.c | 541 +++++++++++++++++++++++++++++++------------------------------
> 1 files changed, 275 insertions(+), 266 deletions(-)
>
> diff --git a/avplay.c b/avplay.c
> index 5fcfaa6..374b72e 100644
> --- a/avplay.c
> +++ b/avplay.c
> @@ -248,19 +248,19 @@ static int fast = 0;
> static int genpts = 0;
> static int lowres = 0;
> static int idct = FF_IDCT_AUTO;
> -static enum AVDiscard skip_frame= AVDISCARD_DEFAULT;
> -static enum AVDiscard skip_idct= AVDISCARD_DEFAULT;
> -static enum AVDiscard skip_loop_filter= AVDISCARD_DEFAULT;
> +static enum AVDiscard skip_frame = AVDISCARD_DEFAULT;
> +static enum AVDiscard skip_idct = AVDISCARD_DEFAULT;
> +static enum AVDiscard skip_loop_filter = AVDISCARD_DEFAULT;
Vertical alignment.
> @@ -822,45 +822,45 @@ static void video_audio_display(VideoState *s)
>
> fgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff);
>
> - for(ch = 1;ch < nb_display_channels; ch++) {
> + for (ch = 1; ch < nb_display_channels; ch++) {
> y = s->ytop + ch * h;
> fill_rectangle(screen,
> s->xleft, y, s->width, 1,
> fgcolor);
> }
> SDL_UpdateRect(screen, s->xleft, s->ytop, s->width, s->height);
> - }else{
> + } else {
> nb_display_channels= FFMIN(nb_display_channels, 2);
> - if(rdft_bits != s->rdft_bits){
> + if (rdft_bits != s->rdft_bits) {
> av_rdft_end(s->rdft);
> av_free(s->rdft_data);
> s->rdft = av_rdft_init(rdft_bits, DFT_R2C);
> s->rdft_bits= rdft_bits;
> - s->rdft_data= av_malloc(4*nb_freq*sizeof(*s->rdft_data));
> + s->rdft_data= av_malloc(4 * nb_freq * sizeof(*s->rdft_data));
Missing space.
> }
> {
> FFTSample *data[2];
> - for(ch = 0;ch < nb_display_channels; ch++) {
> - data[ch] = s->rdft_data + 2*nb_freq*ch;
> + for (ch = 0; ch < nb_display_channels; ch++) {
> + data[ch] = s->rdft_data + 2 * nb_freq * ch;
> i = i_start + ch;
> - for(x = 0; x < 2*nb_freq; x++) {
> - double w= (x-nb_freq)*(1.0/nb_freq);
> - data[ch][x]= s->sample_array[i]*(1.0-w*w);
> + for (x = 0; x < 2 * nb_freq; x++) {
> + double w = (x-nb_freq) * (1.0 / nb_freq);
> + data[ch][x] = s->sample_array[i] * (1.0 - w * w);
> i += channels;
> if (i >= SAMPLE_ARRAY_SIZE)
> i -= SAMPLE_ARRAY_SIZE;
> }
> av_rdft_calc(s->rdft, data[ch]);
> }
> - //least efficient way to do this, we should of course directly
> access it but its more than fast enough
> - for(y=0; y<s->height; y++){
> - double w= 1/sqrt(nb_freq);
> - int a= sqrt(w*sqrt(data[0][2*y+0]*data[0][2*y+0] +
> data[0][2*y+1]*data[0][2*y+1]));
> - int b= (nb_display_channels == 2 ) ?
> sqrt(w*sqrt(data[1][2*y+0]*data[1][2*y+0]
> - + data[1][2*y+1]*data[1][2*y+1])) : a;
> - a= FFMIN(a,255);
> - b= FFMIN(b,255);
> - fgcolor = SDL_MapRGB(screen->format, a, b, (a+b)/2);
> + // least efficient way to do this, we should of course directly
> access it but its more than fast enough
> + for (y = 0; y < s->height; y++) {
> + double w = 1 / sqrt(nb_freq);
> + int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y +
> 0] + data[0][2 * y + 1] * data[0][2 * y + 1]));
> + int b = (nb_display_channels == 2 ) ? sqrt(w *
> sqrt(data[1][2 * y + 0] * data[1][2 * y + 0]
> + + data[1][2 * y + 1] * data[1][2 * y + 1])) : a;
> + a = FFMIN(a, 255);
> + b = FFMIN(b, 255);
> + fgcolor = SDL_MapRGB(screen->format, a, b, (a + b) / 2);
>
> fill_rectangle(screen,
> s->xpos, s->height-y, 1, 1,
> @@ -869,30 +869,33 @@ static void video_audio_display(VideoState *s)
> }
> SDL_UpdateRect(screen, s->xpos, s->ytop, 1, s->height);
> s->xpos++;
> - if(s->xpos >= s->width)
> + if (s->xpos >= s->width)
> s->xpos= s->xleft;
> }
> }
>
> -static int video_open(VideoState *is){
> - int flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
> +static int video_open(VideoState *is)
> +{
> + int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
> int w,h;
>
> - if(is_full_screen) flags |= SDL_FULLSCREEN;
> - else flags |= SDL_RESIZABLE;
> + if (is_full_screen)
> + flags |= SDL_FULLSCREEN;
> + else
> + flags |= SDL_RESIZABLE;
I'd leave the original version here, it's more readable
IMO.
flags |= is_full_screen ? SDL_FULLSCREEN : SDL_RESIZABLE;
would be even better, but it's not cosmetics so would have
to be in a separate patch.
> @@ -1566,8 +1570,10 @@ static int input_get_buffer(AVCodecContext *codec,
> AVFrame *pic)
> pic->opaque = ref;
> pic->type = FF_BUFFER_TYPE_USER;
> pic->reordered_opaque = codec->reordered_opaque;
> - if(codec->pkt) pic->pkt_pts = codec->pkt->pts;
> - else pic->pkt_pts = AV_NOPTS_VALUE;
> + if (codec->pkt)
> + pic->pkt_pts = codec->pkt->pts;
> + else
> + pic->pkt_pts = AV_NOPTS_VALUE;
Same as above, the original is better.
> return 0;
> }
>
> @@ -1593,8 +1599,10 @@ static int input_reget_buffer(AVCodecContext *codec,
> AVFrame *pic)
> }
>
> pic->reordered_opaque = codec->reordered_opaque;
> - if(codec->pkt) pic->pkt_pts = codec->pkt->pts;
> - else pic->pkt_pts = AV_NOPTS_VALUE;
> + if (codec->pkt)
> + pic->pkt_pts = codec->pkt->pts;
> + else
> + pic->pkt_pts = AV_NOPTS_VALUE;
And here as well.
> @@ -2179,15 +2188,15 @@ static int stream_component_open(VideoState *is, int
> stream_index)
> avctx->debug = debug;
> avctx->workaround_bugs = workaround_bugs;
> avctx->lowres = lowres;
> - if(lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
> - avctx->idct_algo= idct;
> - if(fast) avctx->flags2 |= CODEC_FLAG2_FAST;
> - avctx->skip_frame= skip_frame;
> - avctx->skip_idct= skip_idct;
> - avctx->skip_loop_filter= skip_loop_filter;
> - avctx->error_recognition= error_recognition;
> - avctx->error_concealment= error_concealment;
> - avctx->thread_count= thread_count;
> + if (lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
> + avctx->idct_algo = idct;
> + if (fast) avctx->flags2 |= CODEC_FLAG2_FAST;
> + avctx->skip_frame = skip_frame;
> + avctx->skip_idct = skip_idct;
> + avctx->skip_loop_filter = skip_loop_filter;
> + avctx->error_recognition = error_recognition;
> + avctx->error_concealment = error_concealment;
> + avctx->thread_count = thread_count;
Put those if()s together and separate them from the other assignments by
a newline. And vertically align everything.
> @@ -2486,16 +2495,16 @@ static int decode_thread(void *arg)
> }
> #endif
> if (is->seek_req) {
> - int64_t seek_target= is->seek_pos;
> - int64_t seek_min= is->seek_rel > 0 ? seek_target - is->seek_rel
> + 2: INT64_MIN;
> - int64_t seek_max= is->seek_rel < 0 ? seek_target - is->seek_rel
> - 2: INT64_MAX;
> -//FIXME the +-2 is due to rounding being not done in the correct direction
> in generation
> + int64_t seek_target = is->seek_pos;
> + int64_t seek_min = is->seek_rel > 0 ? seek_target - is->seek_rel
> + 2: INT64_MIN;
> + int64_t seek_max = is->seek_rel < 0 ? seek_target - is->seek_rel
> - 2: INT64_MAX;
Vertically align the = (by adding space before =, so you keep 'seek'
aligned as well)
> @@ -2813,33 +2822,33 @@ static void event_loop(void)
> break;
> }
> case SDL_MOUSEMOTION:
> - if(event.type ==SDL_MOUSEBUTTONDOWN){
> - x= event.button.x;
> - }else{
> - if(event.motion.state != SDL_PRESSED)
> + if (event.type == SDL_MOUSEBUTTONDOWN) {
> + x = event.button.x;
> + } else {
> + if (event.motion.state != SDL_PRESSED)
> break;
> - x= event.motion.x;
> + x = event.motion.x;
> }
> if (cur_stream) {
> - if(seek_by_bytes || cur_stream->ic->duration<=0){
> - uint64_t size= avio_size(cur_stream->ic->pb);
> + if (seek_by_bytes || cur_stream->ic->duration <= 0) {
> + uint64_t size = avio_size(cur_stream->ic->pb);
> stream_seek(cur_stream, size*x/cur_stream->width, 0, 1);
> - }else{
> + } else {
> int64_t ts;
> int ns, hh, mm, ss;
> int tns, thh, tmm, tss;
> - tns = cur_stream->ic->duration/1000000LL;
> - thh = tns/3600;
> - tmm = (tns%3600)/60;
> - tss = (tns%60);
> - frac = x/cur_stream->width;
> - ns = frac*tns;
> - hh = ns/3600;
> - mm = (ns%3600)/60;
> - ss = (ns%60);
> + tns = cur_stream->ic->duration / 1000000LL;
> + thh = tns / 3600;
> + tmm = (tns % 3600) / 60;
> + tss = (tns % 60);
> + frac = x / cur_stream->width;
> + ns = frac * tns;
> + hh = ns / 3600;
> + mm = (ns % 3600) / 60;
> + ss = (ns % 60);
Vertically align the =.
> fprintf(stderr, "Seek to %2.0f%% (%2d:%02d:%02d) of
> total duration (%2d:%02d:%02d) \n", frac*100,
> hh, mm, ss, thh, tmm, tss);
> - ts = frac*cur_stream->ic->duration;
> + ts = frac * cur_stream->ic->duration;
> if (cur_stream->ic->start_time != AV_NOPTS_VALUE)
> ts += cur_stream->ic->start_time;
> stream_seek(cur_stream, ts, 0, 0);
> @@ -2850,8 +2859,8 @@ static void event_loop(void)
> if (cur_stream) {
> screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
>
> SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);
> - screen_width = cur_stream->width = event.resize.w;
> - screen_height= cur_stream->height= event.resize.h;
> + screen_width = cur_stream->width = event.resize.w;
> + screen_height= cur_stream->height = event.resize.h;
^
Missing space.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel