Revision f5a478f6 libavformat/dvenc.c

View differences:

libavformat/dvenc.c
29 29
#include "avformat.h"
30 30
#include "dvdata.h"
31 31
#include "dv.h"
32
#include "fifo.h"
32 33

  
33 34
struct DVMuxContext {
34 35
    const DVprofile*  sys;    /* Current DV profile. E.g.: 525/60, 625/50 */
35 36
    int         n_ast;        /* Number of stereo audio streams (up to 2) */
36 37
    AVStream   *ast[2];       /* Stereo audio streams */
37
    FifoBuffer  audio_data[2]; /* Fifo for storing excessive amounts of PCM */
38
    AVFifoBuffer  audio_data[2]; /* Fifo for storing excessive amounts of PCM */
38 39
    int         frames;       /* Number of a current frame */
39 40
    time_t      start_time;   /* Start time of recording */
40 41
    int         has_audio;    /* frame under contruction has audio */
......
185 186
             if (of*2 >= size)
186 187
                 continue;
187 188

  
188
             frame_ptr[d] = fifo_peek(&c->audio_data[channel], of*2+1); // FIXME: may be we have to admit
189
             frame_ptr[d+1] = fifo_peek(&c->audio_data[channel], of*2); //        that DV is a big endian PCM
189
             frame_ptr[d] = av_fifo_peek(&c->audio_data[channel], of*2+1); // FIXME: may be we have to admit
190
             frame_ptr[d+1] = av_fifo_peek(&c->audio_data[channel], of*2); //        that DV is a big endian PCM
190 191
          }
191 192
          frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
192 193
       }
......
247 248
          for (i = 0; i < c->n_ast && st != c->ast[i]; i++);
248 249

  
249 250
          /* FIXME: we have to have more sensible approach than this one */
250
          if (fifo_size(&c->audio_data[i], c->audio_data[i].rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
251
          if (av_fifo_size(&c->audio_data[i]) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
251 252
              av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
252
          fifo_write(&c->audio_data[i], data, data_size, &c->audio_data[i].wptr);
253
          av_fifo_write(&c->audio_data[i], data, data_size);
253 254

  
254 255
          /* Lets see if we've got enough audio for one DV frame */
255
          c->has_audio |= ((reqasize <= fifo_size(&c->audio_data[i], c->audio_data[i].rptr)) << i);
256
          c->has_audio |= ((reqasize <= av_fifo_size(&c->audio_data[i])) << i);
256 257

  
257 258
          break;
258 259
    default:
......
264 265
        dv_inject_metadata(c, *frame);
265 266
        for (i=0; i<c->n_ast; i++) {
266 267
             dv_inject_audio(c, i, *frame);
267
             fifo_drain(&c->audio_data[i], reqasize);
268
             av_fifo_drain(&c->audio_data[i], reqasize);
268 269
        }
269 270

  
270 271
        c->has_video = 0;
......
333 334
    c->start_time = (time_t)s->timestamp;
334 335

  
335 336
    for (i=0; i<c->n_ast; i++) {
336
        if (c->ast[i] && fifo_init(&c->audio_data[i], 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) {
337
        if (c->ast[i] && av_fifo_init(&c->audio_data[i], 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) {
337 338
            while (i>0) {
338 339
                i--;
339
                fifo_free(&c->audio_data[i]);
340
                av_fifo_free(&c->audio_data[i]);
340 341
            }
341 342
            goto bail_out;
342 343
        }
......
353 354
{
354 355
    int i;
355 356
    for (i=0; i < c->n_ast; i++)
356
        fifo_free(&c->audio_data[i]);
357
        av_fifo_free(&c->audio_data[i]);
357 358
}
358 359

  
359 360
#ifdef CONFIG_MUXERS

Also available in: Unified diff