btw, I don't know if there is already a way to do this with an existing utility function... there probably is and I just don't know about it.

I wrote this debugging helper to help me verify input/output PTS in atempo, I can send a patch if it's useful.  Alternatively, I'd like to know what the right way to get the same result would be with existing utility functions


static const char * hh_mm_ss_msec(char buf[15], AVRational b, int64_t t)
{
  char * str = buf;
  t = av_rescale_q(t, b, (AVRational){ 1, 1000 });

  if (t < 0)
  {
    *str++ = '-';
    t = -t;
  }

  // msec:
  {
    char * p = str + 8;
    p[4] = 0;

    p[3] = '0' + (t % 10);
    t /= 10;

    p[2] = '0' + (t % 10);
    t /= 10;

    p[1] = '0' + (t % 10);
    t /= 10;

    p[0] = '.';
  }

  // seconds:
  {
    int64_t v = t % 60;
    char * p = str + 5;

    p[2] = '0' + (v % 10);
    v /= 10;

    p[1] = '0' + v;
    t /= 60;

    p[0] = ':';
  }

  // minutes:
  {
    int64_t v = t % 60;
    char * p = str + 2;

    p[2] = '0' + (v % 10);
    v /= 10;

    p[1] = '0' + v;
    t /= 60;

    p[0] = ':';
  }

  // hours:
  {
    int64_t v = t % 100;
    str[1] = '0' + (v % 10);
    v /= 10;

    str[0] = '0' + v;
  }

  return buf;
}



// elsewhere
    char buf_src[15];
    char buf_dst[15];

...

    av_log(outlink->src, AV_LOG_WARNING,
           "FIXME: pkoshevoy: atempo pts: %s -> %s\n",
           hh_mm_ss_msec(buf_src,
                         (AVRational){ 1, outlink->sample_rate },
                         yae_curr_frag(atempo)->position[0] -
                         yae_curr_frag(atempo)->nsamples),
           hh_mm_ss_msec(buf_dst,
                         outlink->time_base,
                         atempo->dst_buffer->pts));


// and the output looks like this:
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:29.991 -> 
00:00:29.989
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:29.991 -> 
00:00:30.002
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:30.043 -> 
00:00:30.015
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:30.043 -> 
00:00:30.028
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:30.093 -> 
00:00:30.041
[Parsed_atempo_2 @ 0x6a5ec0] FIXME: pkoshevoy: atempo pts: 00:00:30.093 -> 
00:00:30.054

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to