Unverified Commit cb5def22 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Free avPacket on EAGAIN decoder error (#6432) (#6443)

Summary:
Pull Request resolved: https://github.com/pytorch/vision/pull/6432



According to the documentation the packet has to be freed after `av_read_frame()` call.
```
 If pkt->buf is NULL, then the packet is valid until the next
 av_read_frame() or until avformat_close_input(). Otherwise the packet
 is valid indefinitely. In both cases the packet must be freed with
 av_packet_unref when it is no longer needed.
```

Differential Revision: D38747612

fbshipit-source-id: 2e4ccc8365d0d97e5da756ff9c1dcdf27ed323f0
Co-authored-by: default avatarOleksandr Voietsa <ovoietsa@fb.com>
parent c3dc2552
...@@ -516,6 +516,8 @@ int Decoder::getFrame(size_t workingTimeInMs) { ...@@ -516,6 +516,8 @@ int Decoder::getFrame(size_t workingTimeInMs) {
VLOG(4) << "Decoder is busy..."; VLOG(4) << "Decoder is busy...";
std::this_thread::yield(); std::this_thread::yield();
result = 0; // reset error, EAGAIN is not an error at all result = 0; // reset error, EAGAIN is not an error at all
// reset the packet to default settings
av_packet_unref(avPacket);
continue; continue;
} else if (result == AVERROR_EOF) { } else if (result == AVERROR_EOF) {
flushStreams(); flushStreams();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment