[FFmpeg-devel] [PATCH] use strings for error return values in seek_test

Michael Niedermayer michaelni
Fri Oct 2 12:23:34 CEST 2009


On Fri, Oct 02, 2009 at 09:46:46AM +0200, Reimar D?ffinger wrote:
> Hello,
> I have often been wondering what those error "ret" values in seek_test
> actually represent.
> Attached patch uses strings that hopefully make them clearer, and
> hopefully it will indeed fix the DOS regression tests, too.
> Note that I kept/added the - before the EOF etc. because I think it
> makes the output slightly more readable by making the errors stand out
> more.

>  seek.regression.ref |  326 ++++++++++++++++++++++++++--------------------------
>  seek_test.c         |   18 ++
>  2 files changed, 179 insertions(+), 165 deletions(-)
> 7f801c07374fcc9068fc02d1a36a934d8b686d44  seekt_errorstr.diff

[...]
> Index: tests/seek_test.c
> ===================================================================
> --- tests/seek_test.c	(revision 20105)
> +++ tests/seek_test.c	(working copy)
> @@ -30,6 +30,20 @@
>  #undef printf
>  #undef fprintf
>  
> +static char buffer[20];
> +
> +static char *ret_str(int v)
> +{
> +    switch (v) {
> +    case AVERROR_EOF:     return "-EOF";
> +    case AVERROR(EIO):    return "-EIO";
> +    case AVERROR(ENOMEM): return "-ENOMEM";
> +    case AVERROR(EINVAL): return "-EINVAL";
> +    }
> +    snprintf(buffer, sizeof(buffer), "%2d", v);
> +    return buffer;

a default: would look more consistent


> +}
> +
>  int main(int argc, char **argv)
>  {
>      const char *filename;
> @@ -78,7 +92,7 @@
>          memset(&pkt, 0, sizeof(pkt));
>          if(ret>=0){
>              ret= av_read_frame(ic, &pkt);
> -            printf("ret:%2d", ret);
> +            printf("ret:%s", ret_str(ret));

something to make this constant size so that vertical alignment is maintained
would be nice

>              if(ret>=0){
>                  st= ic->streams[pkt.stream_index];
>                  printf(" st:%2d dts:%f pts:%f pos:%" PRId64 " size:%d flags:%d", pkt.stream_index, pkt.dts*av_q2d(st->time_base), pkt.pts*av_q2d(st->time_base), pkt.pos, pkt.size, pkt.flags);
> @@ -97,7 +111,7 @@
>          //FIXME fully test the new seek API
>          if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0);
>          else    ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, INT64_MAX, 0);
> -        printf("ret:%2d st:%2d ts:%f flags:%d\n", ret, stream_id, timestamp*(stream_id<0 ? 1.0/AV_TIME_BASE : av_q2d(st->time_base)), i&1);
> +        printf("ret:%s st:%2d ts:%f flags:%d\n", ret_str(ret), stream_id, timestamp*(stream_id<0 ? 1.0/AV_TIME_BASE : av_q2d(st->time_base)), i&1);
>      }

same

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091002/def71aac/attachment.pgp>



More information about the ffmpeg-devel mailing list