This is not public API, no it has no need for an alloc() and free() functions. The struct can reside on stack.
Showing the changes to libavfilter (11 of 13 files). Show all
Unified · Split
| @@ -23,18 +23,6 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include "ccfifo.h" | 24 | #include "ccfifo.h" |
| 25 | 25 | ||
| 26 | struct AVCCFifo { | ||
| 27 | AVFifo *cc_608_fifo; | ||
| 28 | AVFifo *cc_708_fifo; | ||
| 29 | AVRational framerate; | ||
| 30 | int expected_cc_count; | ||
| 31 | int expected_608; | ||
| 32 | int cc_detected; | ||
| 33 | int passthrough; | ||
| 34 | int passthrough_warning; | ||
| 35 | void *log_ctx; | ||
| 36 | }; | ||
| 37 | |||
| 38 | #define MAX_CC_ELEMENTS 128 | 26 | #define MAX_CC_ELEMENTS 128 |
| 39 | #define CC_BYTES_PER_ENTRY 3 | 27 | #define CC_BYTES_PER_ENTRY 3 |
| 40 | 28 | ||
| @@ -55,25 +43,18 @@ const static struct cc_lookup cc_lookup_vals[] = { · 14 unmodified lines | |||
| 55 | { 60000, 1001, 10, 1}, | 43 | { 60000, 1001, 10, 1}, |
| 56 | }; | 44 | }; |
| 57 | 45 | ||
| 58 | void ff_ccfifo_freep(AVCCFifo **ccf) | 46 | void ff_ccfifo_uninit(CCFifo *ccf) |
| 59 | { | 47 | { |
| 60 | AVCCFifo *tmp = *ccf; | 48 | av_fifo_freep2(&ccf->cc_608_fifo); |
| 61 | if (tmp) { | 49 | av_fifo_freep2(&ccf->cc_708_fifo); |
| 62 | av_fifo_freep2(&tmp->cc_608_fifo); | 50 | memset(ccf, 0, sizeof(*ccf)); |
| 63 | av_fifo_freep2(&tmp->cc_708_fifo); | ||
| 64 | } | ||
| 65 | av_freep(ccf); | ||
| 66 | } | 51 | } |
| 67 | 52 | ||
| 68 | AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx) | 53 | int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx) |
| 69 | { | 54 | { |
| 70 | AVCCFifo *ccf; | ||
| 71 | int i; | 55 | int i; |
| 72 | 56 | ||
| 73 | ccf = av_mallocz(sizeof(*ccf)); | 57 | memset(ccf, 0, sizeof(*ccf)); |
| 74 | if (!ccf) | ||
| 75 | return NULL; | ||
| 76 | |||
| 77 | ccf->log_ctx = log_ctx; | 58 | ccf->log_ctx = log_ctx; |
| 78 | ccf->framerate = framerate; | 59 | ccf->framerate = framerate; |
| 79 | 60 | ||
| @@ -101,24 +82,24 @@ AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx) · 21 unmodified lines | |||
| 101 | ccf->passthrough = 1; | 82 | ccf->passthrough = 1; |
| 102 | } | 83 | } |
| 103 | 84 | ||
| 104 | return ccf; | 85 | return 0; |
| 105 | 86 | ||
| 106 | error: | 87 | error: |
| 107 | ff_ccfifo_freep(&ccf); | 88 | ff_ccfifo_uninit(ccf); |
| 108 | return NULL; | 89 | return AVERROR(ENOMEM); |
| 109 | } | 90 | } |
| 110 | 91 | ||
| 111 | int ff_ccfifo_getoutputsize(AVCCFifo *ccf) | 92 | int ff_ccfifo_getoutputsize(CCFifo *ccf) |
| 112 | { | 93 | { |
| 113 | return ccf->expected_cc_count * CC_BYTES_PER_ENTRY; | 94 | return ccf->expected_cc_count * CC_BYTES_PER_ENTRY; |
| 114 | } | 95 | } |
| 115 | 96 | ||
| 116 | int ff_ccfifo_ccdetected(AVCCFifo *ccf) | 97 | int ff_ccfifo_ccdetected(CCFifo *ccf) |
| 117 | { | 98 | { |
| 118 | return ccf->cc_detected; | 99 | return ccf->cc_detected; |
| 119 | } | 100 | } |
| 120 | 101 | ||
| 121 | int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *cc_data, size_t len) | 102 | int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *cc_data, size_t len) |
| 122 | { | 103 | { |
| 123 | int cc_608_tuples = 0; | 104 | int cc_608_tuples = 0; |
| 124 | int cc_708_tuples = 0; | 105 | int cc_708_tuples = 0; |
| @@ -159,7 +140,7 @@ int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *cc_data, size_t len) · 34 unmodified lines | |||
| 159 | return 0; | 140 | return 0; |
| 160 | } | 141 | } |
| 161 | 142 | ||
| 162 | int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame) | 143 | int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame) |
| 163 | { | 144 | { |
| 164 | AVFrameSideData *sd; | 145 | AVFrameSideData *sd; |
| 165 | int ret; | 146 | int ret; |
| @@ -180,7 +161,7 @@ int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame) · 14 unmodified lines | |||
| 180 | return 0; | 161 | return 0; |
| 181 | } | 162 | } |
| 182 | 163 | ||
| 183 | int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *cc_bytes, size_t len) | 164 | int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *cc_bytes, size_t len) |
| 184 | { | 165 | { |
| 185 | int cc_count = len / CC_BYTES_PER_ENTRY; | 166 | int cc_count = len / CC_BYTES_PER_ENTRY; |
| 186 | 167 | ||
| @@ -209,7 +190,7 @@ int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *cc_bytes, size_t len) · 22 unmodified lines | |||
| 209 | /* Read the A53 side data, discard padding, and put 608/708 into | 190 | /* Read the A53 side data, discard padding, and put 608/708 into |
| 210 | queues so we can ensure they get into the output frames at | 191 | queues so we can ensure they get into the output frames at |
| 211 | the correct rate... */ | 192 | the correct rate... */ |
| 212 | int ff_ccfifo_extract(AVCCFifo *ccf, AVFrame *frame) | 193 | int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame) |
| 213 | { | 194 | { |
| 214 | AVFrameSideData *side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC); | 195 | AVFrameSideData *side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC); |
| 215 | if (side_data) { | 196 | if (side_data) { |
| @@ -33,25 +33,33 @@ · 32 unmodified lines | |||
| 33 | #include "libavutil/frame.h" | 33 | #include "libavutil/frame.h" |
| 34 | #include "libavutil/fifo.h" | 34 | #include "libavutil/fifo.h" |
| 35 | 35 | ||
| 36 | typedef struct AVCCFifo AVCCFifo; | 36 | typedef struct CCFifo { |
| 37 | AVFifo *cc_608_fifo; | ||
| 38 | AVFifo *cc_708_fifo; | ||
| 39 | AVRational framerate; | ||
| 40 | int expected_cc_count; | ||
| 41 | int expected_608; | ||
| 42 | int cc_detected; | ||
| 43 | int passthrough; | ||
| 44 | int passthrough_warning; | ||
| 45 | void *log_ctx; | ||
| 46 | } CCFifo; | ||
| 37 | 47 | ||
| 38 | /** | 48 | /** |
| 39 | * Allocate an AVCCFifo. | 49 | * Initialize a CCFifo. |
| 40 | * | 50 | * |
| 41 | * @param framerate output framerate | 51 | * @param framerate output framerate |
| 42 | * @param log_ctx used for any av_log() calls | 52 | * @param log_ctx used for any av_log() calls |
| 43 | * @return newly allocated AVCCFifo, or NULL on error | 53 | * @return Zero on success, or negative AVERROR code on failure. |
| 44 | */ | 54 | */ |
| 45 | AVCCFifo *ff_ccfifo_alloc(AVRational framerate, void *log_ctx); | 55 | int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx); |
| 46 | 56 | ||
| 47 | /** | 57 | /** |
| 48 | * Free an AVCCFifo | 58 | * Free all memory allocated in a CCFifo and clear the context. |
| 49 | * | 59 | * |
| 50 | * @param ccf Pointer to the pointer to the AVCCFifo which should be freed | 60 | * @param ccf Pointer to the CCFifo which should be uninitialized |
| 51 | * @note `*ptr = NULL` is safe and leads to no action. | ||
| 52 | */ | 61 | */ |
| 53 | void ff_ccfifo_freep(AVCCFifo **ccf); | 62 | void ff_ccfifo_uninit(CCFifo *ccf); |
| 54 | |||
| 55 | 63 | ||
| 56 | /** | 64 | /** |
| 57 | * Extract CC data from an AVFrame | 65 | * Extract CC data from an AVFrame |
| @@ -61,17 +69,17 @@ void ff_ccfifo_freep(AVCCFifo **ccf); · 3 unmodified lines | |||
| 61 | * as it will be re-inserted at the appropriate rate later in the | 69 | * as it will be re-inserted at the appropriate rate later in the |
| 62 | * filter. | 70 | * filter. |
| 63 | * | 71 | * |
| 64 | * @param af AVCCFifo to write to | 72 | * @param af CCFifo to write to |
| 65 | * @param frame AVFrame with the video frame to operate on | 73 | * @param frame AVFrame with the video frame to operate on |
| 66 | * @return Zero on success, or negative AVERROR | 74 | * @return Zero on success, or negative AVERROR |
| 67 | * code on failure. | 75 | * code on failure. |
| 68 | */ | 76 | */ |
| 69 | int ff_ccfifo_extract(AVCCFifo *ccf, AVFrame *frame); | 77 | int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame); |
| 70 | 78 | ||
| 71 | /** | 79 | /** |
| 72 | *Just like ff_ccfifo_extract(), but takes the raw bytes instead of an AVFrame | 80 | *Just like ff_ccfifo_extract(), but takes the raw bytes instead of an AVFrame |
| 73 | */ | 81 | */ |
| 74 | int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *data, size_t len); | 82 | int ff_ccfifo_extractbytes(CCFifo *ccf, uint8_t *data, size_t len); |
| 75 | 83 | ||
| 76 | /** | 84 | /** |
| 77 | * Provide the size in bytes of an output buffer to allocate | 85 | * Provide the size in bytes of an output buffer to allocate |
| @@ -80,7 +88,7 @@ int ff_ccfifo_extractbytes(AVCCFifo *ccf, uint8_t *data, size_t len); · 2 unmodified lines | |||
| 80 | * an appropriately sized buffer and pass it to ff_ccfifo_injectbytes() | 88 | * an appropriately sized buffer and pass it to ff_ccfifo_injectbytes() |
| 81 | * | 89 | * |
| 82 | */ | 90 | */ |
| 83 | int ff_ccfifo_getoutputsize(AVCCFifo *ccf); | 91 | int ff_ccfifo_getoutputsize(CCFifo *ccf); |
| 84 | 92 | ||
| 85 | /** | 93 | /** |
| 86 | * Insert CC data from the FIFO into an AVFrame (as side data) | 94 | * Insert CC data from the FIFO into an AVFrame (as side data) |
| @@ -88,23 +96,23 @@ int ff_ccfifo_getoutputsize(AVCCFifo *ccf); · 1 unmodified line | |||
| 88 | * Dequeue the appropriate number of CC tuples based on the | 96 | * Dequeue the appropriate number of CC tuples based on the |
| 89 | * frame rate, and insert them into the AVFrame | 97 | * frame rate, and insert them into the AVFrame |
| 90 | * | 98 | * |
| 91 | * @param af AVCCFifo to read from | 99 | * @param af CCFifo to read from |
| 92 | * @param frame AVFrame with the video frame to operate on | 100 | * @param frame AVFrame with the video frame to operate on |
| 93 | * @return Zero on success, or negative AVERROR | 101 | * @return Zero on success, or negative AVERROR |
| 94 | * code on failure. | 102 | * code on failure. |
| 95 | */ | 103 | */ |
| 96 | int ff_ccfifo_inject(AVCCFifo *ccf, AVFrame *frame); | 104 | int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame); |
| 97 | 105 | ||
| 98 | /** | 106 | /** |
| 99 | * Just like ff_ccfifo_inject(), but takes the raw bytes to insert the CC data | 107 | * Just like ff_ccfifo_inject(), but takes the raw bytes to insert the CC data |
| 100 | * int rather than an AVFrame | 108 | * int rather than an AVFrame |
| 101 | */ | 109 | */ |
| 102 | int ff_ccfifo_injectbytes(AVCCFifo *ccf, uint8_t *data, size_t len); | 110 | int ff_ccfifo_injectbytes(CCFifo *ccf, uint8_t *data, size_t len); |
| 103 | 111 | ||
| 104 | /** | 112 | /** |
| 105 | * Returns 1 if captions have been found as a prior call | 113 | * Returns 1 if captions have been found as a prior call |
| 106 | * to ff_ccfifo_extract() or ff_ccfifo_extractbytes() | 114 | * to ff_ccfifo_extract() or ff_ccfifo_extractbytes() |
| 107 | */ | 115 | */ |
| 108 | int ff_ccfifo_ccdetected(AVCCFifo *ccf); | 116 | int ff_ccfifo_ccdetected(CCFifo *ccf); |
| 109 | 117 | ||
| 110 | #endif /* AVFILTER_CCFIFO_H */ | 118 | #endif /* AVFILTER_CCFIFO_H */ |
| @@ -78,7 +78,7 @@ typedef struct TInterlaceContext { · 77 unmodified lines | |||
| 78 | const AVPixFmtDescriptor *csp; | 78 | const AVPixFmtDescriptor *csp; |
| 79 | void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, | 79 | void (*lowpass_line)(uint8_t *dstp, ptrdiff_t width, const uint8_t *srcp, |
| 80 | ptrdiff_t mref, ptrdiff_t pref, int clip_max); | 80 | ptrdiff_t mref, ptrdiff_t pref, int clip_max); |
| 81 | AVCCFifo *cc_fifo; | 81 | CCFifo cc_fifo; |
| 82 | } TInterlaceContext; | 82 | } TInterlaceContext; |
| 83 | 83 | ||
| 84 | void ff_tinterlace_init_x86(TInterlaceContext *interlace); | 84 | void ff_tinterlace_init_x86(TInterlaceContext *interlace); |
| @@ -297,7 +297,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 296 unmodified lines | |||
| 297 | av_frame_free(&yadif->prev); | 297 | av_frame_free(&yadif->prev); |
| 298 | av_frame_free(&yadif->cur ); | 298 | av_frame_free(&yadif->cur ); |
| 299 | av_frame_free(&yadif->next); | 299 | av_frame_free(&yadif->next); |
| 300 | ff_ccfifo_freep(&yadif->cc_fifo); | 300 | ff_ccfifo_uninit(&yadif->cc_fifo); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static const enum AVPixelFormat pix_fmts[] = { | 303 | static const enum AVPixelFormat pix_fmts[] = { |
| @@ -326,6 +326,7 @@ static int config_props(AVFilterLink *link) · 22 unmodified lines | |||
| 326 | AVFilterContext *ctx = link->src; | 326 | AVFilterContext *ctx = link->src; |
| 327 | BWDIFContext *s = link->src->priv; | 327 | BWDIFContext *s = link->src->priv; |
| 328 | YADIFContext *yadif = &s->yadif; | 328 | YADIFContext *yadif = &s->yadif; |
| 329 | int ret; | ||
| 329 | 330 | ||
| 330 | link->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); | 331 | link->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); |
| 331 | link->w = link->src->inputs[0]->w; | 332 | link->w = link->src->inputs[0]->w; |
| @@ -336,9 +337,10 @@ static int config_props(AVFilterLink *link) · 4 unmodified lines | |||
| 336 | else | 337 | else |
| 337 | link->frame_rate = ctx->inputs[0]->frame_rate; | 338 | link->frame_rate = ctx->inputs[0]->frame_rate; |
| 338 | 339 | ||
| 339 | if (!(yadif->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) { | 340 | ret = ff_ccfifo_init(&yadif->cc_fifo, link->frame_rate, ctx); |
| 341 | if (ret < 0 ) { | ||
| 340 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 342 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 341 | return AVERROR(ENOMEM); | 343 | return ret; |
| 342 | } | 344 | } |
| 343 | 345 | ||
| 344 | if (link->w < 3 || link->h < 4) { | 346 | if (link->w < 3 || link->h < 4) { |
| @@ -37,7 +37,7 @@ · 36 unmodified lines | |||
| 37 | typedef struct CCRepackContext | 37 | typedef struct CCRepackContext |
| 38 | { | 38 | { |
| 39 | const AVClass *class; | 39 | const AVClass *class; |
| 40 | AVCCFifo *cc_fifo; | 40 | CCFifo cc_fifo; |
| 41 | } CCRepackContext; | 41 | } CCRepackContext; |
| 42 | 42 | ||
| 43 | static const AVOption ccrepack_options[] = { | 43 | static const AVOption ccrepack_options[] = { |
| @@ -50,9 +50,10 @@ static int config_input(AVFilterLink *link) · 6 unmodified lines | |||
| 50 | { | 50 | { |
| 51 | CCRepackContext *ctx = link->dst->priv; | 51 | CCRepackContext *ctx = link->dst->priv; |
| 52 | 52 | ||
| 53 | if (!(ctx->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) { | 53 | int ret = ff_ccfifo_init(&ctx->cc_fifo, link->frame_rate, ctx); |
| 54 | if (ret < 0) { | ||
| 54 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 55 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 55 | return AVERROR(ENOMEM); | 56 | return ret; |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | return 0; | 59 | return 0; |
| @@ -63,8 +64,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 4 unmodified lines | |||
| 63 | CCRepackContext *ctx = inlink->dst->priv; | 64 | CCRepackContext *ctx = inlink->dst->priv; |
| 64 | AVFilterLink *outlink = inlink->dst->outputs[0]; | 65 | AVFilterLink *outlink = inlink->dst->outputs[0]; |
| 65 | 66 | ||
| 66 | ff_ccfifo_extract(ctx->cc_fifo, frame); | 67 | ff_ccfifo_extract(&ctx->cc_fifo, frame); |
| 67 | ff_ccfifo_inject(ctx->cc_fifo, frame); | 68 | ff_ccfifo_inject(&ctx->cc_fifo, frame); |
| 68 | 69 | ||
| 69 | return ff_filter_frame(outlink, frame); | 70 | return ff_filter_frame(outlink, frame); |
| 70 | } | 71 | } |
| @@ -72,7 +73,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 1 unmodified line | |||
| 72 | static av_cold void uninit(AVFilterContext *ctx) | 73 | static av_cold void uninit(AVFilterContext *ctx) |
| 73 | { | 74 | { |
| 74 | CCRepackContext *s = ctx->priv; | 75 | CCRepackContext *s = ctx->priv; |
| 75 | ff_ccfifo_freep(&s->cc_fifo); | 76 | ff_ccfifo_uninit(&s->cc_fifo); |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | static const AVFilterPad avfilter_vf_ccrepack_inputs[] = { | 79 | static const AVFilterPad avfilter_vf_ccrepack_inputs[] = { |
| @@ -86,7 +86,7 @@ typedef struct FPSContext { · 85 unmodified lines | |||
| 86 | 86 | ||
| 87 | AVFrame *frames[2]; ///< buffered frames | 87 | AVFrame *frames[2]; ///< buffered frames |
| 88 | int frames_count; ///< number of buffered frames | 88 | int frames_count; ///< number of buffered frames |
| 89 | AVCCFifo *cc_fifo; ///< closed captions | 89 | CCFifo cc_fifo; ///< closed captions |
| 90 | 90 | ||
| 91 | int64_t next_pts; ///< pts of the next frame to output | 91 | int64_t next_pts; ///< pts of the next frame to output |
| 92 | 92 | ||
| @@ -167,7 +167,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 74 unmodified lines | |||
| 167 | frame = shift_frame(ctx, s); | 167 | frame = shift_frame(ctx, s); |
| 168 | av_frame_free(&frame); | 168 | av_frame_free(&frame); |
| 169 | } | 169 | } |
| 170 | ff_ccfifo_freep(&s->cc_fifo); | 170 | ff_ccfifo_uninit(&s->cc_fifo); |
| 171 | 171 | ||
| 172 | av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, " | 172 | av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, " |
| 173 | "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup); | 173 | "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup); |
| @@ -213,9 +213,10 @@ static int config_props(AVFilterLink* outlink) · 39 unmodified lines | |||
| 213 | s->in_pts_off, s->out_pts_off, s->start_time); | 213 | s->in_pts_off, s->out_pts_off, s->start_time); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | if (!(s->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) { | 216 | ret = ff_ccfifo_init(&s->cc_fifo, outlink->frame_rate, ctx); |
| 217 | if (ret < 0) { | ||
| 217 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 218 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 218 | return AVERROR(ENOMEM); | 219 | return ret; |
| 219 | } | 220 | } |
| 220 | 221 | ||
| 221 | av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den); | 222 | av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den); |
| @@ -250,7 +251,7 @@ static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, · 28 unmodified lines | |||
| 250 | av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n", | 251 | av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n", |
| 251 | in_pts, frame->pts); | 252 | in_pts, frame->pts); |
| 252 | 253 | ||
| 253 | ff_ccfifo_extract(s->cc_fifo, frame); | 254 | ff_ccfifo_extract(&s->cc_fifo, frame); |
| 254 | s->frames[s->frames_count++] = frame; | 255 | s->frames[s->frames_count++] = frame; |
| 255 | s->frames_in++; | 256 | s->frames_in++; |
| 256 | 257 | ||
| @@ -298,7 +299,7 @@ static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlin · 41 unmodified lines | |||
| 298 | if (!frame) | 299 | if (!frame) |
| 299 | return AVERROR(ENOMEM); | 300 | return AVERROR(ENOMEM); |
| 300 | // Make sure Closed Captions will not be duplicated | 301 | // Make sure Closed Captions will not be duplicated |
| 301 | ff_ccfifo_inject(s->cc_fifo, frame); | 302 | ff_ccfifo_inject(&s->cc_fifo, frame); |
| 302 | frame->pts = s->next_pts++; | 303 | frame->pts = s->next_pts++; |
| 303 | frame->duration = 1; | 304 | frame->duration = 1; |
| 304 | 305 | ||
| @@ -203,7 +203,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 202 unmodified lines | |||
| 203 | av_frame_free(&tinterlace->next); | 203 | av_frame_free(&tinterlace->next); |
| 204 | av_freep(&tinterlace->black_data[0][0]); | 204 | av_freep(&tinterlace->black_data[0][0]); |
| 205 | av_freep(&tinterlace->black_data[1][0]); | 205 | av_freep(&tinterlace->black_data[1][0]); |
| 206 | ff_ccfifo_freep(&tinterlace->cc_fifo); | 206 | ff_ccfifo_uninit(&tinterlace->cc_fifo); |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | static int config_out_props(AVFilterLink *outlink) | 209 | static int config_out_props(AVFilterLink *outlink) |
| @@ -212,7 +212,7 @@ static int config_out_props(AVFilterLink *outlink) · 2 unmodified lines | |||
| 212 | AVFilterLink *inlink = outlink->src->inputs[0]; | 212 | AVFilterLink *inlink = outlink->src->inputs[0]; |
| 213 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); | 213 | const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format); |
| 214 | TInterlaceContext *tinterlace = ctx->priv; | 214 | TInterlaceContext *tinterlace = ctx->priv; |
| 215 | int i; | 215 | int ret, i; |
| 216 | 216 | ||
| 217 | tinterlace->vsub = desc->log2_chroma_h; | 217 | tinterlace->vsub = desc->log2_chroma_h; |
| 218 | outlink->w = inlink->w; | 218 | outlink->w = inlink->w; |
| @@ -224,7 +224,6 @@ static int config_out_props(AVFilterLink *outlink) · 5 unmodified lines | |||
| 224 | 224 | ||
| 225 | if (tinterlace->mode == MODE_PAD) { | 225 | if (tinterlace->mode == MODE_PAD) { |
| 226 | uint8_t black[4] = { 0, 0, 0, 16 }; | 226 | uint8_t black[4] = { 0, 0, 0, 16 }; |
| 227 | int ret; | ||
| 228 | ff_draw_init(&tinterlace->draw, outlink->format, 0); | 227 | ff_draw_init(&tinterlace->draw, outlink->format, 0); |
| 229 | ff_draw_color(&tinterlace->draw, &tinterlace->color, black); | 228 | ff_draw_color(&tinterlace->draw, &tinterlace->color, black); |
| 230 | /* limited range */ | 229 | /* limited range */ |
| @@ -292,9 +291,10 @@ static int config_out_props(AVFilterLink *outlink) · 61 unmodified lines | |||
| 292 | #endif | 291 | #endif |
| 293 | } | 292 | } |
| 294 | 293 | ||
| 295 | if (!(tinterlace->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) { | 294 | ret = ff_ccfifo_init(&tinterlace->cc_fifo, outlink->frame_rate, ctx); |
| 295 | if (ret < 0) { | ||
| 296 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 296 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 297 | return AVERROR(ENOMEM); | 297 | return ret; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, | 300 | av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, |
| @@ -381,7 +381,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) · 80 unmodified lines | |||
| 381 | tinterlace->cur = tinterlace->next; | 381 | tinterlace->cur = tinterlace->next; |
| 382 | tinterlace->next = picref; | 382 | tinterlace->next = picref; |
| 383 | 383 | ||
| 384 | ff_ccfifo_extract(tinterlace->cc_fifo, picref); | 384 | ff_ccfifo_extract(&tinterlace->cc_fifo, picref); |
| 385 | 385 | ||
| 386 | cur = tinterlace->cur; | 386 | cur = tinterlace->cur; |
| 387 | next = tinterlace->next; | 387 | next = tinterlace->next; |
| @@ -464,7 +464,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 76 unmodified lines | |||
| 464 | if (!out) | 464 | if (!out) |
| 465 | return AVERROR(ENOMEM); | 465 | return AVERROR(ENOMEM); |
| 466 | out->pts /= 2; // adjust pts to new framerate | 466 | out->pts /= 2; // adjust pts to new framerate |
| 467 | ff_ccfifo_inject(tinterlace->cc_fifo, out); | 467 | ff_ccfifo_inject(&tinterlace->cc_fifo, out); |
| 468 | ret = ff_filter_frame(outlink, out); | 468 | ret = ff_filter_frame(outlink, out); |
| 469 | return ret; | 469 | return ret; |
| 470 | } | 470 | } |
| @@ -514,7 +514,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 43 unmodified lines | |||
| 514 | out->pts = cur->pts*2; | 514 | out->pts = cur->pts*2; |
| 515 | 515 | ||
| 516 | out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); | 516 | out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); |
| 517 | ff_ccfifo_inject(tinterlace->cc_fifo, out); | 517 | ff_ccfifo_inject(&tinterlace->cc_fifo, out); |
| 518 | if ((ret = ff_filter_frame(outlink, out)) < 0) | 518 | if ((ret = ff_filter_frame(outlink, out)) < 0) |
| 519 | return ret; | 519 | return ret; |
| 520 | 520 | ||
| @@ -559,7 +559,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 38 unmodified lines | |||
| 559 | 559 | ||
| 560 | out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); | 560 | out->pts = av_rescale_q(out->pts, tinterlace->preout_time_base, outlink->time_base); |
| 561 | out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); | 561 | out->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); |
| 562 | ff_ccfifo_inject(tinterlace->cc_fifo, out); | 562 | ff_ccfifo_inject(&tinterlace->cc_fifo, out); |
| 563 | ret = ff_filter_frame(outlink, out); | 563 | ret = ff_filter_frame(outlink, out); |
| 564 | 564 | ||
| 565 | return ret; | 565 | return ret; |
| @@ -261,7 +261,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 260 unmodified lines | |||
| 261 | av_frame_free(&yadif->prev); | 261 | av_frame_free(&yadif->prev); |
| 262 | av_frame_free(&yadif->cur ); | 262 | av_frame_free(&yadif->cur ); |
| 263 | av_frame_free(&yadif->next); | 263 | av_frame_free(&yadif->next); |
| 264 | ff_ccfifo_freep(&yadif->cc_fifo); | 264 | ff_ccfifo_uninit(&yadif->cc_fifo); |
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | static const enum AVPixelFormat pix_fmts[] = { | 267 | static const enum AVPixelFormat pix_fmts[] = { |
| @@ -286,6 +286,7 @@ static int config_output(AVFilterLink *outlink) · 18 unmodified lines | |||
| 286 | { | 286 | { |
| 287 | AVFilterContext *ctx = outlink->src; | 287 | AVFilterContext *ctx = outlink->src; |
| 288 | YADIFContext *s = ctx->priv; | 288 | YADIFContext *s = ctx->priv; |
| 289 | int ret; | ||
| 289 | 290 | ||
| 290 | outlink->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); | 291 | outlink->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); |
| 291 | outlink->w = ctx->inputs[0]->w; | 292 | outlink->w = ctx->inputs[0]->w; |
| @@ -297,9 +298,10 @@ static int config_output(AVFilterLink *outlink) · 5 unmodified lines | |||
| 297 | else | 298 | else |
| 298 | outlink->frame_rate = ctx->inputs[0]->frame_rate; | 299 | outlink->frame_rate = ctx->inputs[0]->frame_rate; |
| 299 | 300 | ||
| 300 | if (!(s->cc_fifo = ff_ccfifo_alloc(outlink->frame_rate, ctx))) { | 301 | ret = ff_ccfifo_init(&s->cc_fifo, outlink->frame_rate, ctx); |
| 302 | if (ret < 0) { | ||
| 301 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 303 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 302 | return AVERROR(ENOMEM); | 304 | return ret; |
| 303 | } | 305 | } |
| 304 | 306 | ||
| 305 | if (outlink->w < 3 || outlink->h < 3) { | 307 | if (outlink->w < 3 || outlink->h < 3) { |
| @@ -205,7 +205,7 @@ static av_cold void deint_cuda_uninit(AVFilterContext *ctx) · 204 unmodified lines | |||
| 205 | av_frame_free(&y->prev); | 205 | av_frame_free(&y->prev); |
| 206 | av_frame_free(&y->cur); | 206 | av_frame_free(&y->cur); |
| 207 | av_frame_free(&y->next); | 207 | av_frame_free(&y->next); |
| 208 | ff_ccfifo_freep(&y->cc_fifo); | 208 | ff_ccfifo_uninit(&y->cc_fifo); |
| 209 | 209 | ||
| 210 | av_buffer_unref(&s->device_ref); | 210 | av_buffer_unref(&s->device_ref); |
| 211 | s->hwctx = NULL; | 211 | s->hwctx = NULL; |
| @@ -295,9 +295,9 @@ static int config_output(AVFilterLink *link) · 83 unmodified lines | |||
| 295 | else | 295 | else |
| 296 | link->frame_rate = ctx->inputs[0]->frame_rate; | 296 | link->frame_rate = ctx->inputs[0]->frame_rate; |
| 297 | 297 | ||
| 298 | if (!(y->cc_fifo = ff_ccfifo_alloc(link->frame_rate, ctx))) { | 298 | ret = ff_ccfifo_init(&y->cc_fifo, link->frame_rate, ctx); |
| 299 | if (ret < 0) { | ||
| 299 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); | 300 | av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); |
| 300 | ret = AVERROR(ENOMEM); | ||
| 301 | goto exit; | 301 | goto exit; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| @@ -77,7 +77,7 @@ typedef struct YADIFContext { · 76 unmodified lines | |||
| 77 | int eof; | 77 | int eof; |
| 78 | uint8_t *temp_line; | 78 | uint8_t *temp_line; |
| 79 | int temp_line_size; | 79 | int temp_line_size; |
| 80 | AVCCFifo *cc_fifo; | 80 | CCFifo cc_fifo; |
| 81 | 81 | ||
| 82 | /* | 82 | /* |
| 83 | * An algorithm that treats first and/or last fields in a sequence | 83 | * An algorithm that treats first and/or last fields in a sequence |
| @@ -66,7 +66,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 65 unmodified lines | |||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | ff_ccfifo_inject(yadif->cc_fifo, yadif->out); | 69 | ff_ccfifo_inject(&yadif->cc_fifo, yadif->out); |
| 70 | ret = ff_filter_frame(ctx->outputs[0], yadif->out); | 70 | ret = ff_filter_frame(ctx->outputs[0], yadif->out); |
| 71 | 71 | ||
| 72 | yadif->frame_pending = (yadif->mode&1) && !is_second; | 72 | yadif->frame_pending = (yadif->mode&1) && !is_second; |
| @@ -103,7 +103,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 30 unmodified lines | |||
| 103 | 103 | ||
| 104 | av_assert0(frame); | 104 | av_assert0(frame); |
| 105 | 105 | ||
| 106 | ff_ccfifo_extract(yadif->cc_fifo, frame); | 106 | ff_ccfifo_extract(&yadif->cc_fifo, frame); |
| 107 | 107 | ||
| 108 | if (yadif->frame_pending) | 108 | if (yadif->frame_pending) |
| 109 | return_frame(ctx, 1); | 109 | return_frame(ctx, 1); |
| @@ -146,7 +146,7 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) · 36 unmodified lines | |||
| 146 | if (!yadif->out) | 146 | if (!yadif->out) |
| 147 | return AVERROR(ENOMEM); | 147 | return AVERROR(ENOMEM); |
| 148 | 148 | ||
| 149 | ff_ccfifo_inject(yadif->cc_fifo, yadif->out); | 149 | ff_ccfifo_inject(&yadif->cc_fifo, yadif->out); |
| 150 | av_frame_free(&yadif->prev); | 150 | av_frame_free(&yadif->prev); |
| 151 | if (yadif->out->pts != AV_NOPTS_VALUE) | 151 | if (yadif->out->pts != AV_NOPTS_VALUE) |
| 152 | yadif->out->pts *= 2; | 152 | yadif->out->pts *= 2; |