~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavcodec/utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-03-13 09:18:28 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090313091828-n4ktby5eca487uhv
Tags: 3:0.svn20090303-1ubuntu1+unstripped1
merge from ubuntu.jaunty branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
    else  return first_avcodec;
89
89
}
90
90
 
91
 
void register_avcodec(AVCodec *codec)
 
91
void avcodec_register(AVCodec *codec)
92
92
{
93
93
    AVCodec **p;
94
94
    avcodec_init();
98
98
    codec->next = NULL;
99
99
}
100
100
 
 
101
#if LIBAVCODEC_VERSION_MAJOR < 53
 
102
void register_avcodec(AVCodec *codec)
 
103
{
 
104
    avcodec_register(codec);
 
105
}
 
106
#endif
 
107
 
101
108
void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
102
109
    s->coded_width = width;
103
110
    s->coded_height= height;
154
161
            h_align=4;
155
162
        }
156
163
    case PIX_FMT_PAL8:
 
164
    case PIX_FMT_BGR8:
 
165
    case PIX_FMT_RGB8:
157
166
        if(s->codec_id == CODEC_ID_SMC){
158
167
            w_align=4;
159
168
            h_align=4;
262
271
        }
263
272
 
264
273
        tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
 
274
        if (tmpsize < 0)
 
275
            return -1;
265
276
 
266
277
        for (i=0; i<3 && picture.data[i+1]; i++)
267
278
            size[i] = picture.data[i+1] - picture.data[i];
281
292
            if(buf->base[i]==NULL) return -1;
282
293
            memset(buf->base[i], 128, size[i]);
283
294
 
284
 
            // no edge if EDEG EMU or not planar YUV, we check for PAL8 redundantly to protect against a exploitable bug regression ...
285
 
            if((s->flags&CODEC_FLAG_EMU_EDGE) || (s->pix_fmt == PIX_FMT_PAL8) || !size[2])
 
295
            // no edge if EDEG EMU or not planar YUV
 
296
            if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2])
286
297
                buf->data[i] = buf->base[i];
287
298
            else
288
299
                buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]);
289
300
        }
 
301
        if(size[1] && !size[2])
 
302
            ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt);
290
303
        buf->width  = s->width;
291
304
        buf->height = s->height;
292
305
        buf->pix_fmt= s->pix_fmt;
380
393
    return 0;
381
394
}
382
395
 
383
 
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt){
 
396
enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt){
 
397
    while (*fmt != PIX_FMT_NONE && ff_is_hwaccel_pix_fmt(*fmt))
 
398
        ++fmt;
384
399
    return fmt[0];
385
400
}
386
401
 
460
475
        return -1;
461
476
    }
462
477
    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || samples){
463
 
        int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)samples);
 
478
        int ret = avctx->codec->encode(avctx, buf, buf_size, samples);
464
479
        avctx->frame_number++;
465
480
        return ret;
466
481
    }else
477
492
    if(avcodec_check_dimensions(avctx,avctx->width,avctx->height))
478
493
        return -1;
479
494
    if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
480
 
        int ret = avctx->codec->encode(avctx, buf, buf_size, (void *)pict);
 
495
        int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
481
496
        avctx->frame_number++;
482
497
        emms_c(); //needed to avoid an emms_c() call before every return;
483
498
 
490
505
                            const AVSubtitle *sub)
491
506
{
492
507
    int ret;
493
 
    ret = avctx->codec->encode(avctx, buf, buf_size, (void *)sub);
 
508
    if(sub->start_display_time) {
 
509
        av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n");
 
510
        return -1;
 
511
    }
 
512
    if(sub->num_rects == 0 || !sub->rects)
 
513
        return -1;
 
514
    ret = avctx->codec->encode(avctx, buf, buf_size, sub);
494
515
    avctx->frame_number++;
495
516
    return ret;
496
517
}
1021
1042
{
1022
1043
    int i;
1023
1044
    int n = FF_ARRAY_ELEMS(video_frame_size_abbrs);
1024
 
    const char *p;
 
1045
    char *p;
1025
1046
    int frame_width = 0, frame_height = 0;
1026
1047
 
1027
1048
    for(i=0;i<n;i++) {
1033
1054
    }
1034
1055
    if (i == n) {
1035
1056
        p = str;
1036
 
        frame_width = strtol(p, (char **)&p, 10);
 
1057
        frame_width = strtol(p, &p, 10);
1037
1058
        if (*p)
1038
1059
            p++;
1039
 
        frame_height = strtol(p, (char **)&p, 10);
 
1060
        frame_height = strtol(p, &p, 10);
1040
1061
    }
1041
1062
    if (frame_width <= 0 || frame_height <= 0)
1042
1063
        return -1;
1103
1124
            "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
1104
1125
            "and contact the ffmpeg-devel mailing list.\n");
1105
1126
}
 
1127
 
 
1128
static AVHWAccel *first_hwaccel = NULL;
 
1129
 
 
1130
void av_register_hwaccel(AVHWAccel *hwaccel)
 
1131
{
 
1132
    AVHWAccel **p = &first_hwaccel;
 
1133
    while (*p)
 
1134
        p = &(*p)->next;
 
1135
    *p = hwaccel;
 
1136
    hwaccel->next = NULL;
 
1137
}
 
1138
 
 
1139
AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
 
1140
{
 
1141
    return hwaccel ? hwaccel->next : first_hwaccel;
 
1142
}
 
1143
 
 
1144
AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt)
 
1145
{
 
1146
    AVHWAccel *hwaccel=NULL;
 
1147
 
 
1148
    while((hwaccel= av_hwaccel_next(hwaccel))){
 
1149
        if (   hwaccel->id      == codec_id
 
1150
            && hwaccel->pix_fmt == pix_fmt)
 
1151
            return hwaccel;
 
1152
    }
 
1153
    return NULL;
 
1154
}