Commit 4e309734 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Fix the handling of discard_before_pts (#2841)

Summary:
Currently `discard_before_pts=-1` is used to indicate no AVFrame should be skipped. It was reported that some corrupted video can have constant negative pts value.

It is technically UB for such corrupted data, but still all the AVFrame should be decoded as long as `seek` is not used.

This commit changes the decoder so that it processes AVFrame if `discard_before_pts==-1` disregard of AVFrame::pts value.

Pull Request resolved: https://github.com/pytorch/audio/pull/2841

Reviewed By: hwangjeff

Differential Revision: D41174442

Pulled By: mthrok

fbshipit-source-id: e9d2fab4b0e2bc47146eda8e1dd377a74c087590
parent 15f76b0b
...@@ -83,7 +83,7 @@ int StreamProcessor::process_packet( ...@@ -83,7 +83,7 @@ int StreamProcessor::process_packet(
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pFrame1->pts >= discard_before_pts) { if (discard_before_pts < 0 || pFrame1->pts >= discard_before_pts) {
send_frame(pFrame1); send_frame(pFrame1);
} }
......
...@@ -18,6 +18,8 @@ class StreamReader { ...@@ -18,6 +18,8 @@ class StreamReader {
std::vector<std::pair<int, int>> stream_indices; std::vector<std::pair<int, int>> stream_indices;
// timestamp to seek to expressed in AV_TIME_BASE // timestamp to seek to expressed in AV_TIME_BASE
// < 0 : No seek
// Positive value: Skip AVFrames with timestamps before it
int64_t seek_timestamp = -1; int64_t seek_timestamp = -1;
public: public:
......
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