From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 3298E4B974 for ; Tue, 22 Jul 2025 12:37:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id B4B1968CFB1; Tue, 22 Jul 2025 15:36:44 +0300 (EEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 084DB68CF5E for ; Tue, 22 Jul 2025 15:36:42 +0300 (EEST) Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-23636167afeso51055585ad.3 for ; Tue, 22 Jul 2025 05:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753187801; x=1753792601; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QHUSdDo4wU/+LGjq2tayPBhuD+S3LShP7CV6DhlFTyc=; b=AtTQNgOF8bTO49uH2hXgXtIG3R9cPGRh8Yg3WTXyVTmI8VmTwacW23TJ6Uhm4t6X2e rR6hbTq5bHtP43GTiubZr2A2IyRloYFFL8vFmtJ+UC8WdbsBjXqrL1YUyH7py3abymWx UmPKd7HidYVUtrj8OSviPrsB7i1Xgz362Su+z8BXOV9tTETCYXCdjiMv3jMZYVJLh5tn bm2vvWexTjB7FTforNt6ACE2hwQxt1TMbzCc4zOx5mMXqfb4SJShyhN75bw3qR8iFBeW HLhkmq7XcLJ5VRN8raHVPVipOEIuwTrPI18BY8mwnbU7LzBl8CKyrcEnvwUpIZ+Tfepw 15ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753187801; x=1753792601; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QHUSdDo4wU/+LGjq2tayPBhuD+S3LShP7CV6DhlFTyc=; b=vMiFMsB4Mq0tZ/fhd9iBCC/98xSS04XE4Ur8w66QnKqm76p/ALLX1ufe3rgM2l7N6T jdp5E1NB9s1IWqfL0blgRLs/CccjVusbr3JQloUMnVbxZRotphqcJu0rRhoG8baBGKAY QZM+WQQXPeHEzY/uN9YwGMlOmw2TDqdTuSO45uTSxUWYVtsGZOGomgdBT32Nqj0pDvt8 iNFfmfCn3bKp/iyo7SKPO99FnVONalY0QzCkYqby6ssLpJekgsbCTKQkfL0myUdhk7XC 4qBZQRSWQaWyhZF6/fsJYwnQmOO2niNXWOje1G3AqrTXfxyF+uJalh6xUI2mNXomhTWy kaaA== X-Gm-Message-State: AOJu0Yx874OmsQSJ2nPeyOij6obQjCqwGkq27GJUxIT8hLffrg4cuRNu VuOrr/eULkbwbx7FFIEPg4shY/m6aoKUtl7SwSPKpnHS2tg64VB857y2IoW+D6hZZVQ= X-Gm-Gg: ASbGncsNRrPb3L42+erTv1yh9pgOrMYXio50rKM7ZJPfT7tzYaBJTPeWOxQzTZySS21 4b+Fn7gjkuwHlfdbpVgK081OSrzjXyOegB+Pw3heXiLYwCgEMOLp2hREqYbgJ+7RI0qJYxzc/IT QghbTrkW/tMNsjgWgyEx+PDRDQUNwWaWMxocDRvcWtoqyq6kbhG6WZU7F2dkJOW6ite3y2vTIW2 AwYCuGAaD2ZEjeyd7eSlswAps1gKcCyR6HzY8MQuTpStKE43sGY5QAqXImx7tE4iLCBpfTAN60S O6CegZtHwfmLm2vRwBc5Eo+en9NdaPEpv0R4JoMBaEdKS6ahlfInHUfUfd1DMxDAamuK8JA9X+J Y4T0ag2agZMcbfwSRiuxpYAEGjvCncp2YLSXvQLkxXCUZAQ== X-Google-Smtp-Source: AGHT+IHYstEGcgK903BdfsAOaI1NCpZVf9BKxcbUo6M0C8NsA65a6dHFunMoVJLhFNWBpXriAS1PZg== X-Received: by 2002:a17:902:c94e:b0:234:ef42:5d65 with SMTP id d9443c01a7336-23e25789acbmr365554645ad.52.1753187800799; Tue, 22 Jul 2025 05:36:40 -0700 (PDT) Received: from localhost.localdomain ([182.126.128.169]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23e3b60edbasm75740715ad.70.2025.07.22.05.36.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Jul 2025 05:36:40 -0700 (PDT) From: Jack Lau X-Google-Original-From: Jack Lau To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Jul 2025 20:36:04 +0800 Message-ID: <20250722123616.53164-4-jacklau1222@qq.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250722123616.53164-1-jacklau1222@qq.com> References: <20250722123616.53164-1-jacklau1222@qq.com> MIME-Version: 1.0 X-Unsent: 1 Subject: [FFmpeg-devel] [PATCH v5 03/15] avformat/whip: fix H264 profile_iop bit map for SDP X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Jack Lau Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: AVCodecParameters::profile only contains constraint_set1_flag (AV_PROFILE_H264_CONSTRAINED 1<<9). So add H264 constraints flag fully parse refer to hlsenc write_codec_attr Signed-off-by: Jack Lau --- libavformat/whip.c | 47 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 3ec4c76b5f..4de8eb2601 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -210,6 +210,7 @@ typedef struct WHIPContext { /* Parameters for the input audio and video codecs. */ AVCodecParameters *audio_par; AVCodecParameters *video_par; + uint8_t constraint_set_flags; /** * The h264_mp4toannexb Bitstream Filter (BSF) bypasses the AnnexB packet; @@ -450,45 +451,30 @@ static av_cold int initialize(AVFormatContext *s) static int parse_profile_level(AVFormatContext *s, AVCodecParameters *par) { int ret = 0; - const uint8_t *r = par->extradata, *r1, *end = par->extradata + par->extradata_size; - H264SPS seq, *const sps = &seq; - uint32_t state; + const uint8_t *r = par->extradata; WHIPContext *whip = s->priv_data; if (par->codec_id != AV_CODEC_ID_H264) return ret; - if (par->profile != AV_PROFILE_UNKNOWN && par->level != AV_LEVEL_UNKNOWN) - return ret; - if (!par->extradata || par->extradata_size <= 0) { av_log(whip, AV_LOG_ERROR, "Unable to parse profile from empty extradata=%p, size=%d\n", par->extradata, par->extradata_size); return AVERROR(EINVAL); } - while (1) { - r = avpriv_find_start_code(r, end, &state); - if (r >= end) - break; - - r1 = ff_nal_find_startcode(r, end); - if ((state & 0x1f) == H264_NAL_SPS) { - ret = ff_avc_decode_sps(sps, r, r1 - r); - if (ret < 0) { - av_log(whip, AV_LOG_ERROR, "Failed to decode SPS, state=%x, size=%d\n", - state, (int)(r1 - r)); - return ret; - } - - av_log(whip, AV_LOG_VERBOSE, "Parse profile=%d, level=%d from SPS\n", - sps->profile_idc, sps->level_idc); - par->profile = sps->profile_idc; - par->level = sps->level_idc; - } + if (AV_RB32(r) == 0x00000001 && (r[4] & 0x1F) == 7) + r = &r[5]; + else if (AV_RB24(r) == 0x000001 && (r[3] & 0x1F) == 7) + r = &r[4]; + else if (r[0] == 0x01) // avcC + r = &r[1]; + else + return AVERROR(EINVAL); - r = r1; - } + if (par->profile == AV_PROFILE_UNKNOWN) par->profile = r[0]; + whip->constraint_set_flags = r[1]; + if (par->level == AV_LEVEL_UNKNOWN) par->level = r[2]; return ret; } @@ -599,7 +585,7 @@ static int parse_codec(AVFormatContext *s) */ static int generate_sdp_offer(AVFormatContext *s) { - int ret = 0, profile, level, profile_iop; + int ret = 0, profile, level; const char *acodec_name = NULL, *vcodec_name = NULL; AVBPrint bp; WHIPContext *whip = s->priv_data; @@ -667,11 +653,10 @@ static int generate_sdp_offer(AVFormatContext *s) } if (whip->video_par) { - profile_iop = profile = whip->video_par->profile; + profile = whip->video_par->profile; level = whip->video_par->level; if (whip->video_par->codec_id == AV_CODEC_ID_H264) { vcodec_name = "H264"; - profile_iop &= AV_PROFILE_H264_CONSTRAINED; profile &= (~AV_PROFILE_H264_CONSTRAINED); } @@ -699,7 +684,7 @@ static int generate_sdp_offer(AVFormatContext *s) vcodec_name, whip->video_payload_type, profile, - profile_iop, + whip->constraint_set_flags, level, whip->video_ssrc, whip->video_ssrc); -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".