| @@ -30,6 +30,8 @@ static inline FFFrameBucket *bucket(FFFrameQueue *fq, size_t idx) · 29 unmodified lines |
| 30 | | 30 | |
| 31 | void ff_framequeue_global_init(FFFrameQueueGlobal *fqg) | 31 | void ff_framequeue_global_init(FFFrameQueueGlobal *fqg) |
| 32 | { | 32 | { |
| | 33 | fqg->max_queued = SIZE_MAX; |
| | 34 | fqg->queued = 0; |
| 33 | } | 35 | } |
| 34 | | 36 | |
| 35 | static void check_consistency(FFFrameQueue *fq) | 37 | static void check_consistency(FFFrameQueue *fq) |
| @@ -49,6 +51,7 @@ void ff_framequeue_init(FFFrameQueue *fq, FFFrameQueueGlobal *fqg) · 13 unmodified lines |
| 49 | { | 51 | { |
| 50 | fq->queue = &fq->first_bucket; | 52 | fq->queue = &fq->first_bucket; |
| 51 | fq->allocated = 1; | 53 | fq->allocated = 1; |
| | 54 | fq->global = fqg; |
| 52 | } | 55 | } |
| 53 | | 56 | |
| 54 | void ff_framequeue_free(FFFrameQueue *fq) | 57 | void ff_framequeue_free(FFFrameQueue *fq) |
| @@ -66,6 +69,8 @@ int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame) · 11 unmodified lines |
| 66 | FFFrameBucket *b; | 69 | FFFrameBucket *b; |
| 67 | | 70 | |
| 68 | check_consistency(fq); | 71 | check_consistency(fq); |
| | 72 | if (fq->global->queued >= fq->global->max_queued) |
| | 73 | return AVERROR(ENOMEM); |
| 69 | if (fq->queued == fq->allocated) { | 74 | if (fq->queued == fq->allocated) { |
| 70 | if (fq->allocated == 1) { | 75 | if (fq->allocated == 1) { |
| 71 | size_t na = 8; | 76 | size_t na = 8; |
| @@ -89,6 +94,7 @@ int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame) · 17 unmodified lines |
| 89 | b = bucket(fq, fq->queued); | 94 | b = bucket(fq, fq->queued); |
| 90 | b->frame = frame; | 95 | b->frame = frame; |
| 91 | fq->queued++; | 96 | fq->queued++; |
| | 97 | fq->global->queued++; |
| 92 | fq->total_frames_head++; | 98 | fq->total_frames_head++; |
| 93 | fq->total_samples_head += frame->nb_samples; | 99 | fq->total_samples_head += frame->nb_samples; |
| 94 | check_consistency(fq); | 100 | check_consistency(fq); |
| @@ -103,6 +109,7 @@ AVFrame *ff_framequeue_take(FFFrameQueue *fq) · 8 unmodified lines |
| 103 | av_assert1(fq->queued); | 109 | av_assert1(fq->queued); |
| 104 | b = bucket(fq, 0); | 110 | b = bucket(fq, 0); |
| 105 | fq->queued--; | 111 | fq->queued--; |
| | 112 | fq->global->queued--; |
| 106 | fq->tail++; | 113 | fq->tail++; |
| 107 | fq->tail &= fq->allocated - 1; | 114 | fq->tail &= fq->allocated - 1; |
| 108 | fq->total_frames_tail++; | 115 | fq->total_frames_tail++; |