Skip to content

Commit

Permalink
缓和切换速率
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleychen committed Mar 11, 2024
1 parent c2a7609 commit b667e51
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
46 changes: 45 additions & 1 deletion ijkmedia/ijkplayer/ff_ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ static void check_external_clock_speed(VideoState *is, FFPlayer *ffp) {
}
#endif

#if 0
static int temp_packet_num = 0;
if ((temp_packet_num > 0) || (ffp->packet_max_num > 0)) {
temp_packet_num = ffp->packet_max_num;
Expand Down Expand Up @@ -1252,7 +1253,50 @@ static void check_external_clock_speed(VideoState *is, FFPlayer *ffp) {
set_clock_speed(&is->extclk, 1);
}
}
//#endif
#endif
if (is->video_stream > 0) {
if (is->videoq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES) { //if (is->videoq.nb_packets > temp_packet_num) {

int synctype = get_master_sync_type(is);
if (synctype == AV_SYNC_AUDIO_MASTER) {
// printf("speeddddddd===audio===packets===>%d\n",is->videoq.nb_packets);
if (ffp->audio_speed > 1) {
ffp_set_playback_rate(ffp, ffp->audio_speed);
}else {
ffp_set_playback_rate(ffp, EXTERNAL_CLOCK_SPEED_MAX);
}
}else {
// printf("speeddddddd===exter===packets===>%d\n",is->videoq.nb_packets);
set_clock_speed(&is->extclk, EXTERNAL_CLOCK_SPEED_MAX);
}

}else if (is->videoq.nb_packets < EXTERNAL_CLOCK_MIN_FRAMES) {

ffp_set_playback_rate(ffp, 1);
double speed = is->extclk.speed;
if (speed != 1.0) {
set_clock_speed(&is->extclk, 1);
}
}
}
else {
//only audio stream
if (is->audio_stream >= 0) {
if (is->audioq.nb_packets > EXTERNAL_CLOCK_MAX_FRAMES) {
if (ffp->audio_speed > 1) {
ffp_set_playback_rate(ffp, ffp->audio_speed);
}else {
ffp_set_playback_rate(ffp, EXTERNAL_CLOCK_SPEED_MAX);
}
}else if (is->audioq.nb_packets < EXTERNAL_CLOCK_MIN_FRAMES){
ffp_set_playback_rate(ffp, 1);
double speed = is->extclk.speed;
if (speed != 1.0) {
set_clock_speed(&is->extclk, 1);
}
}
}
}
}

/* seek in the stream */
Expand Down
4 changes: 2 additions & 2 deletions ijkmedia/ijkplayer/ff_ffplay_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
#define MIN_MIN_FRAMES 2
#define MAX_MIN_FRAMES 50000
#define MIN_FRAMES (ffp->dcc.min_frames)
#define EXTERNAL_CLOCK_MIN_FRAMES 0
#define EXTERNAL_CLOCK_MAX_FRAMES 5
#define EXTERNAL_CLOCK_MIN_FRAMES 3
#define EXTERNAL_CLOCK_MAX_FRAMES 10

/* Minimum SDL audio buffer size, in samples. */
#define SDL_AUDIO_MIN_BUFFER_SIZE 512
Expand Down

0 comments on commit b667e51

Please sign in to comment.