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 D73CC40280 for ; Wed, 2 Jul 2025 12:00:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id DCF5E68D055; Wed, 2 Jul 2025 15:00:24 +0300 (EEST) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 1643C68CFA0 for ; Wed, 2 Jul 2025 15:00:17 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2366e5e4dbaso64277145ad.1 for ; Wed, 02 Jul 2025 05:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751457615; x=1752062415; 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=zWwC2Sx6k4ft3vozuhJrMLiJJVlcFHRwqzVr4zlz/o0=; b=ehvXKXR/CsaApAseqYlt4WSZ4xWB3Oj9ODlE9LZdeMGbxCDhUsdzSUX/Cerna+ENT5 MlaVfAa7ynGW6m8INaBs/tpWqlws1IdrDWBhYsL1S3bulVozwhKuFnYDx1pNLLMNwJ/g Mf0wvmy5UmP50M/AcJ7RJYL3jZ9qyLZnyhVXrT3y8lW5h1jSREB1e4z3MGf01fdjuMJN QzXN58TgWSOAA3b/wXAeijNTyYUHjOKARqh8i36trefbgNJyQWtwoA7dNtV9aUsX48Sx PZmxWaztWLkpwR2NVhwiDr08YFCSZxg6RdDGmg0DdHMU13hIQLq7YUlgR6s1zqbX8SRv jhlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751457615; x=1752062415; 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=zWwC2Sx6k4ft3vozuhJrMLiJJVlcFHRwqzVr4zlz/o0=; b=mjGtsH9jSrlqlR3/Y9tUpIAN3+CZpooR6C6mxIHIvbdVumJ50+nTa58qW2J2eY+e9a nyFvD7URBjRRTO54oydTQ/yenGw9EMEzcmle63xPoZ4fPm3k/gUoLKP0SjX6WWLSMAQN FkLOX1b9uafrmq+a42g0yIMu/3nV0lz9jDUfJj7j8/q9X+ocRTErZMNlWT+gaNvaWHT/ Tq6OYbSC/bHgGtJhL2UgrOo1r+WsezLjvNuzSNMBImLYkIUeuSJKGBs/bSA0B19JD3W0 z7843PdbOh4iKZBnxO/nyAFVMNzLqpaK8FqPI0Pm1+UEyyW4O0kluQfTPZcvvDXeh/oR U5Aw== X-Gm-Message-State: AOJu0YxX1k2z+ig+CVee8t2xXLoxcEfvhlH5CNKxWvI6I8olgO3a9ioS OLAmenEC7J1ao3KnHaiiAqiN577bCBgug89R3z05klRrBbmo+zaPNeafc1tSXktFqIHD1Q== X-Gm-Gg: ASbGncsNLuqSCzVed/a/qYoz1ldVK2UIAbvAR+lNBQJP1pLQvUU9UuCx//2Gvyje3Mp fFcwcDLPYISKpMi2gMS5cELLPlme5KDtCDH+tg5QQ7XSnEeN7tee3Dc4nsFBpP0tnkIkyCzuY7j B2jU9iI0MjygS1WeDidgp0XEl0G5Tf+svfnYMOwL8IvYHRQrFOpiYI5D9+gGjrHXc65S7PthGgJ EIWkmjHwgTk44QZ7HRNl9FskYz3jY7h/y2Y7tm4zXU1Sshh3dw+TmDarhGM3CEeR6J/aTx+R0+E WW8/GNzTj3R4+Sx3wT0HjFgXeHId0lN6WWbQRs5SG/ctpl4EmMyypX7eMDzeI3ax6Q== X-Google-Smtp-Source: AGHT+IG9AHiM8leQJsQkJalW3nNU3rdzGK2E4Rx3MLfhKLZik4dQJa5GHoXMDoSEjjP8zlNCR/2v1Q== X-Received: by 2002:a17:902:ec89:b0:234:5ea1:6041 with SMTP id d9443c01a7336-23c6e797229mr36558895ad.10.1751457614544; Wed, 02 Jul 2025 05:00:14 -0700 (PDT) Received: from localhost.localdomain ([5.34.218.79]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23acb39b928sm127504185ad.111.2025.07.02.05.00.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Jul 2025 05:00:14 -0700 (PDT) From: Jack Lau X-Google-Original-From: Jack Lau To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Jul 2025 19:59:52 +0800 Message-ID: <20250702115955.33922-4-jacklau1222@qq.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250702115955.33922-1-jacklau1222@qq.com> References: <20250702115955.33922-1-jacklau1222@qq.com> MIME-Version: 1.0 X-Unsent: 1 Subject: [FFmpeg-devel] [PATCH v2 3/6] 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 932119a1c7..e287a3062f 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; @@ -445,45 +446,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; } @@ -594,7 +580,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; @@ -662,11 +648,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); } @@ -694,7 +679,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".