| 379 | } |
| 380 | |
| 381 | static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, |
| 382 | const AVFrame *frame, int *got_packet_ptr) |
| 383 | { |
| 384 | NellyMoserEncodeContext *s = avctx->priv_data; |
| 385 | int ret; |
| 386 | |
| 387 | if (s->last_frame) |
| 388 | return 0; |
| 389 | |
| 390 | memcpy(s->buf, s->buf + NELLY_SAMPLES, NELLY_BUF_LEN * sizeof(*s->buf)); |
| 391 | if (frame) { |
| 392 | memcpy(s->buf + NELLY_BUF_LEN, frame->data[0], |
| 393 | frame->nb_samples * sizeof(*s->buf)); |
| 394 | if (frame->nb_samples < NELLY_SAMPLES) { |
| 395 | memset(s->buf + NELLY_BUF_LEN + frame->nb_samples, 0, |
| 396 | (NELLY_SAMPLES - frame->nb_samples) * sizeof(*s->buf)); |
| 397 | if (frame->nb_samples >= NELLY_BUF_LEN) |
| 398 | s->last_frame = 1; |
| 399 | } |
| 400 | if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) |
| 401 | return ret; |
| 402 | } else { |
| 403 | memset(s->buf + NELLY_BUF_LEN, 0, NELLY_SAMPLES * sizeof(*s->buf)); |
| 404 | s->last_frame = 1; |
| 405 | } |
| 406 | |
| 407 | if ((ret = ff_get_encode_buffer(avctx, avpkt, NELLY_BLOCK_LEN, 0)) < 0) |
| 408 | return ret; |
| 409 | encode_block(s, avpkt->data, avpkt->size); |
| 410 | |
| 411 | /* Get the next frame pts/duration */ |
| 412 | ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, |
| 413 | &avpkt->duration); |
| 414 | |
| 415 | *got_packet_ptr = 1; |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | const FFCodec ff_nellymoser_encoder = { |
| 420 | .p.name = "nellymoser", |
nothing calls this directly
no test coverage detected