~ubuntu-branches/ubuntu/trusty/gst-libav1.0/trusty-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavutil/parseutils.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-09-24 17:07:00 UTC
  • mfrom: (1.1.17) (7.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130924170700-4dg62s3pwl0pdakz
Tags: 1.2.0-1
* New upstream stable release:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.2.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 * misc parsing utilities
22
22
 */
23
23
 
24
 
#include <sys/time.h>
25
24
#include <time.h>
26
25
 
27
26
#include "avstring.h"
28
27
#include "avutil.h"
 
28
#include "common.h"
29
29
#include "eval.h"
30
30
#include "log.h"
31
31
#include "random_seed.h"
107
107
        }
108
108
    }
109
109
    if (i == n) {
110
 
        p = str;
111
 
        width = strtol(p, &p, 10);
 
110
        width = strtol(str, &p, 10);
112
111
        if (*p)
113
112
            p++;
114
113
        height = strtol(p, &p, 10);
355
354
    }
356
355
 
357
356
    if (tail) {
358
 
        unsigned long int alpha;
 
357
        double alpha;
359
358
        const char *alpha_string = tail;
360
359
        if (!strncmp(alpha_string, "0x", 2)) {
361
360
            alpha = strtoul(alpha_string, &tail, 16);
363
362
            alpha = 255 * strtod(alpha_string, &tail);
364
363
        }
365
364
 
366
 
        if (tail == alpha_string || *tail || alpha > 255) {
 
365
        if (tail == alpha_string || *tail || alpha > 255 || alpha < 0) {
367
366
            av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",
368
367
                   alpha_string, color_string);
369
368
            return AVERROR(EINVAL);
484
483
{
485
484
    const char *p;
486
485
    int64_t t;
487
 
    struct tm dt;
 
486
    struct tm dt = { 0 };
488
487
    int i;
489
488
    static const char * const date_fmt[] = {
490
489
        "%Y-%m-%d",
499
498
    char lastch;
500
499
    int negative = 0;
501
500
 
502
 
#undef time
503
501
    time_t now = time(0);
504
502
 
505
503
    len = strlen(timestr);
509
507
        lastch = '\0';
510
508
    is_utc = (lastch == 'z' || lastch == 'Z');
511
509
 
512
 
    memset(&dt, 0, sizeof(dt));
513
 
 
514
510
    p = timestr;
515
511
    q = NULL;
516
512
    if (!duration) {
646
642
 
647
643
#ifdef TEST
648
644
 
649
 
#undef printf
650
 
 
651
645
int main(void)
652
646
{
653
647
    printf("Testing av_parse_video_rate()\n");
654
648
    {
655
649
        int i;
656
 
        const char *rates[] = {
 
650
        static const char *const rates[] = {
657
651
            "-inf",
658
652
            "inf",
659
653
            "nan",
683
677
 
684
678
        for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
685
679
            int ret;
686
 
            AVRational q = (AVRational){0, 0};
687
 
            ret = av_parse_video_rate(&q, rates[i]),
688
 
            printf("'%s' -> %d/%d ret:%d\n",
689
 
                   rates[i], q.num, q.den, ret);
 
680
            AVRational q = { 0, 0 };
 
681
            ret = av_parse_video_rate(&q, rates[i]);
 
682
            printf("'%s' -> %d/%d %s\n",
 
683
                   rates[i], q.num, q.den, ret ? "ERROR" : "OK");
690
684
        }
691
685
    }
692
686
 
694
688
    {
695
689
        int i;
696
690
        uint8_t rgba[4];
697
 
        const char *color_names[] = {
698
 
            "bikeshed",
699
 
            "RaNdOm",
 
691
        static const char *const color_names[] = {
700
692
            "foo",
701
693
            "red",
702
694
            "Red ",
737
729
 
738
730
        for (i = 0;  i < FF_ARRAY_ELEMS(color_names); i++) {
739
731
            if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
740
 
                printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
 
732
                printf("%s -> R(%d) G(%d) B(%d) A(%d)\n",
 
733
                       color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
741
734
        }
742
735
    }
743
736