Browse Source

Share normative HRD limits with the bitstream validator

master
evgeny 5 days ago
parent
commit
aad77cf415
  1. 5
      src/call/call_video.c
  2. 1
      src/call/call_video.h

5
src/call/call_video.c

@ -119,6 +119,11 @@ unsigned call_video_dpb_limit(int codec, unsigned level, unsigned width, unsigne
unsigned frames = dpb_mbs[l - avc_levels] / (((width + 15) / 16) * ((height + 15) / 16));
return frames < 16 ? frames : 16;
}
int call_video_hrd_valid(int codec, unsigned level, int nal, uint64_t bitrate, uint64_t cpb) {
const struct video_level *l = level <= 255 ? level_find(codec, level) : NULL;
unsigned factor = nal ? (codec == CALL_VIDEO_H264 ? 1200 : 1100) : 1000;
return l && bitrate && cpb && bitrate <= (uint64_t)l->kbps * factor && cpb <= (uint64_t)l->cpb_kbits * factor;
}
int call_video_format_supported(const struct call_video_caps *sender, const struct call_video_caps *receiver,
const struct call_video_format *f) {
return call_video_caps_valid(sender) && call_video_caps_valid(receiver) && call_video_format_valid(f)

1
src/call/call_video.h

@ -64,6 +64,7 @@ int call_video_format_supported(const struct call_video_caps *sender, const stru
int call_video_format_valid(const struct call_video_format *format);
/* Нормативный предел DPB в кадрах по coded geometry и level; 0 при неверном уровне. */
unsigned call_video_dpb_limit(int codec, unsigned level, unsigned width, unsigned height);
int call_video_hrd_valid(int codec, unsigned level, int nal, uint64_t bitrate, uint64_t cpb);
int call_video_same_format(const struct call_video_format *a, const struct call_video_format *b);
int call_video_caps_encode(const struct call_video_caps *caps, uint8_t out[CALL_VIDEO_CAPS_BYTES]);
int call_video_caps_parse(const uint8_t *data, size_t length, struct call_video_caps *out);

Loading…
Cancel
Save