Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 硬解情况下 sps/pps变化时重启解码器继续播放 #5385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,15 @@ static int feed_input_buffer2(JNIEnv *env, IJKFF_Pipenode *node, int64_t timeUs,
avcodec_free_context(&new_avctx);
return change_ret;
} else {
if (opaque->codecpar->width != new_avctx->width &&
opaque->codecpar->height != new_avctx->height) {
AVCodecContext *ic = opaque->decoder->avctx;
// resolution change or extradata change(eg.same resolution video. extradata change contain extradata size change and extradata content change)
if ((opaque->codecpar->width != new_avctx->width && opaque->codecpar->height != new_avctx->height)
|| size_data_size != ic->extradata_size
|| memcmp(ic->extradata, new_avctx->extradata, size_data_size) != 0) {
ALOGW("AV_PKT_DATA_NEW_EXTRADATA: %d x %d\n", new_avctx->width, new_avctx->height);
//update extradata and extradata_size for next extradata change
ic->extradata_size = size_data_size;
ic->extradata = new_avctx->extradata;
avcodec_parameters_from_context(opaque->codecpar, new_avctx);
opaque->aformat_need_recreate = true;
ffpipeline_set_surface_need_reconfigure_l(pipeline, true);
Expand Down Expand Up @@ -799,9 +805,15 @@ static int feed_input_buffer(JNIEnv *env, IJKFF_Pipenode *node, int64_t timeUs,
avcodec_free_context(&new_avctx);
return change_ret;
} else {
if (opaque->codecpar->width != new_avctx->width &&
opaque->codecpar->height != new_avctx->height) {
AVCodecContext *ic = opaque->decoder->avctx;
// resolution change or extradata change(eg.same resolution video. extradata change contain extradata size change and extradata content change)
if ((opaque->codecpar->width != new_avctx->width && opaque->codecpar->height != new_avctx->height)
|| size_data_size != ic->extradata_size
|| memcmp(ic->extradata, new_avctx->extradata, size_data_size) != 0) {
ALOGW("AV_PKT_DATA_NEW_EXTRADATA: %d x %d\n", new_avctx->width, new_avctx->height);
//update extradata and extradata_size for next extradata change
ic->extradata_size = size_data_size;
ic->extradata = new_avctx->extradata;
avcodec_parameters_from_context(opaque->codecpar, new_avctx);
opaque->aformat_need_recreate = true;
ffpipeline_set_surface_need_reconfigure_l(pipeline, true);
Expand Down Expand Up @@ -1126,6 +1138,12 @@ static int drain_output_buffer_l(JNIEnv *env, IJKFF_Pipenode *node, int64_t time
// ffp_notify_msg3(ffp, FFP_MSG_VIDEO_SIZE_CHANGED, width, height);
// opaque->frame_width = width;
// opaque->frame_height = height;

// update frame width and height for send FFP_MSG_VIDEO_SIZE_CHANGED msg on queue_picture method.
if(opaque->ffp->mediacodec_handle_resolution_change && opaque->codecpar->codec_id == AV_CODEC_ID_H264){
opaque->frame_width = width;
opaque->frame_height = height;
}
ALOGI(
"AMEDIACODEC__INFO_OUTPUT_FORMAT_CHANGED\n"
" width-height: (%d x %d)\n"
Expand Down