This does not quite work like avcodec_decode_audio4/avcodec_decode_video2. There is the following difference: if you got a frame, you must call it again with pkt=NULL. pkt==NULL is treated differently from pkt.size==0 (pkt==NULL means get more output, pkt.size==0 is a flush/drain packet)
| 2255 | // it again with pkt=NULL. pkt==NULL is treated differently from pkt.size==0 |
| 2256 | // (pkt==NULL means get more output, pkt.size==0 is a flush/drain packet) |
| 2257 | static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt) |
| 2258 | { |
| 2259 | int ret; |
| 2260 | |
| 2261 | *got_frame = 0; |
| 2262 | |
| 2263 | if (pkt) { |
| 2264 | ret = avcodec_send_packet(avctx, pkt); |
| 2265 | // In particular, we don't expect AVERROR(EAGAIN), because we read all |
| 2266 | // decoded frames with avcodec_receive_frame() until done. |
| 2267 | if (ret < 0 && ret != AVERROR_EOF) |
| 2268 | return ret; |
| 2269 | } |
| 2270 | |
| 2271 | ret = avcodec_receive_frame(avctx, frame); |
| 2272 | if (ret < 0 && ret != AVERROR(EAGAIN)) |
| 2273 | return ret; |
| 2274 | if (ret >= 0) |
| 2275 | *got_frame = 1; |
| 2276 | |
| 2277 | return 0; |
| 2278 | } |
| 2279 | |
| 2280 | static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame) |
| 2281 | { |
no outgoing calls
no test coverage detected