History

avfilter: take_samples: do not directly return frame when samples are skipped

Modifying data pointer when skipping samples may make it unaligned. Workaround for Ticket6349. This should fix the crash of ticket's testcase and a crash/regression with avxsynth (reported by Michael Niedermayer). Also change frame->nb_samples < max to frame->nb_samples <= max. This improves performance. Benchmark: ./ffmpeg -filter_complex "aevalsrc=0:n=1166,firequalizer=fixed=on" -f null null old: 25767 decicycles in take_samples, 1023 runs, 1 skips 25422 decicycles in take_samples, 2047 runs, 1 skips 25181 decicycles in take_samples, 4095 runs, 1 skips 24904 decicycles in take_samples, 8191 runs, 1 skips new: 550 decicycles in take_samples, 1024 runs, 0 skips 548 decicycles in take_samples, 2048 runs, 0 skips 545 decicycles in take_samples, 4096 runs, 0 skips 544 decicycles in take_samples, 8192 runs, 0 skips

Muhammad Faiz committed 9 years ago

Commit fc3a03f1 parent f20161d3 files · +14 −1Browse files

Showing the changes to libavfilter/framequeue.c (1 of 3 files). Show all

Unified · Split

libavfilter/framequeue.c+2−0
@@ -107,6 +107,7 @@ AVFrame *ff_framequeue_take(FFFrameQueue *fq) · 106 unmodified lines
107 fq->tail &= fq->allocated - 1;107 fq->tail &= fq->allocated - 1;
108 fq->total_frames_tail++;108 fq->total_frames_tail++;
109 fq->total_samples_tail += b->frame->nb_samples;109 fq->total_samples_tail += b->frame->nb_samples;
110 fq->samples_skipped = 0;
110 check_consistency(fq);111 check_consistency(fq);
111 return b->frame;112 return b->frame;
112}113}
@@ -146,5 +147,6 @@ void ff_framequeue_skip_samples(FFFrameQueue *fq, size_t samples, AVRational tim · 33 unmodified lines
146 for (i = 0; i < planes && i < AV_NUM_DATA_POINTERS; i++)147 for (i = 0; i < planes && i < AV_NUM_DATA_POINTERS; i++)
147 b->frame->data[i] = b->frame->extended_data[i];148 b->frame->data[i] = b->frame->extended_data[i];
148 fq->total_samples_tail += samples;149 fq->total_samples_tail += samples;
150 fq->samples_skipped = 1;
149 ff_framequeue_update_peeked(fq, 0);151 ff_framequeue_update_peeked(fq, 0);
150}152}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t