mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-15 07:44:10 +00:00
libobs: Expose NAL enums in obs-avc.h
I encountered some cases where I needed to use these enumerations outside of the file, so this allows other modules to use AVC enumerations without having to redefine them each time. Especially useful for custom encoder modules.
This commit is contained in:
parent
923916ecce
commit
f8e56a4e1e
|
@ -19,26 +19,6 @@
|
|||
#include "obs-avc.h"
|
||||
#include "util/array-serializer.h"
|
||||
|
||||
enum {
|
||||
NAL_UNKNOWN = 0,
|
||||
NAL_SLICE = 1,
|
||||
NAL_SLICE_DPA = 2,
|
||||
NAL_SLICE_DPB = 3,
|
||||
NAL_SLICE_DPC = 4,
|
||||
NAL_SLICE_IDR = 5,
|
||||
NAL_SEI = 6,
|
||||
NAL_SPS = 7,
|
||||
NAL_PPS = 8,
|
||||
NAL_AUD = 9,
|
||||
NAL_FILLER = 12,
|
||||
};
|
||||
|
||||
enum {
|
||||
NAL_PRIORITY_DISPOSABLE = 0,
|
||||
NAL_PRIORITY_LOW = 1,
|
||||
NAL_PRIORITY_HIGH = 2,
|
||||
NAL_PRIORITY_HIGHEST = 3,
|
||||
};
|
||||
|
||||
/* NOTE: I noticed that FFmpeg does some unusual special handling of certain
|
||||
* scenarios that I was unaware of, so instead of just searching for {0, 0, 1}
|
||||
|
@ -91,11 +71,11 @@ const uint8_t *obs_avc_find_startcode(const uint8_t *p, const uint8_t *end)
|
|||
static inline int get_drop_priority(int priority)
|
||||
{
|
||||
switch (priority) {
|
||||
case NAL_PRIORITY_DISPOSABLE: return NAL_PRIORITY_DISPOSABLE;
|
||||
case NAL_PRIORITY_LOW: return NAL_PRIORITY_LOW;
|
||||
case OBS_NAL_PRIORITY_DISPOSABLE: return OBS_NAL_PRIORITY_DISPOSABLE;
|
||||
case OBS_NAL_PRIORITY_LOW: return OBS_NAL_PRIORITY_LOW;
|
||||
}
|
||||
|
||||
return NAL_PRIORITY_HIGHEST;
|
||||
return OBS_NAL_PRIORITY_HIGHEST;
|
||||
}
|
||||
|
||||
static void serialize_avc_data(struct serializer *s, const uint8_t *data,
|
||||
|
@ -114,9 +94,9 @@ static void serialize_avc_data(struct serializer *s, const uint8_t *data,
|
|||
|
||||
type = nal_start[0] & 0x1F;
|
||||
|
||||
if (type == NAL_SLICE_IDR || type == NAL_SLICE) {
|
||||
if (type == OBS_NAL_SLICE_IDR || type == OBS_NAL_SLICE) {
|
||||
if (is_keyframe)
|
||||
*is_keyframe = (type == NAL_SLICE_IDR);
|
||||
*is_keyframe = (type == OBS_NAL_SLICE_IDR);
|
||||
if (priority)
|
||||
*priority = nal_start[0] >> 5;
|
||||
}
|
||||
|
@ -171,10 +151,10 @@ static void get_sps_pps(const uint8_t *data, size_t size,
|
|||
nal_end = obs_avc_find_startcode(nal_start, end);
|
||||
|
||||
type = nal_start[0] & 0x1F;
|
||||
if (type == NAL_SPS) {
|
||||
if (type == OBS_NAL_SPS) {
|
||||
*sps = nal_start;
|
||||
*sps_size = nal_end - nal_start;
|
||||
} else if (type == NAL_PPS) {
|
||||
} else if (type == OBS_NAL_PPS) {
|
||||
*pps = nal_start;
|
||||
*pps_size = nal_end - nal_start;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,27 @@ extern "C" {
|
|||
|
||||
struct encoder_packet;
|
||||
|
||||
enum {
|
||||
OBS_NAL_UNKNOWN = 0,
|
||||
OBS_NAL_SLICE = 1,
|
||||
OBS_NAL_SLICE_DPA = 2,
|
||||
OBS_NAL_SLICE_DPB = 3,
|
||||
OBS_NAL_SLICE_DPC = 4,
|
||||
OBS_NAL_SLICE_IDR = 5,
|
||||
OBS_NAL_SEI = 6,
|
||||
OBS_NAL_SPS = 7,
|
||||
OBS_NAL_PPS = 8,
|
||||
OBS_NAL_AUD = 9,
|
||||
OBS_NAL_FILLER = 12,
|
||||
};
|
||||
|
||||
enum {
|
||||
OBS_NAL_PRIORITY_DISPOSABLE = 0,
|
||||
OBS_NAL_PRIORITY_LOW = 1,
|
||||
OBS_NAL_PRIORITY_HIGH = 2,
|
||||
OBS_NAL_PRIORITY_HIGHEST = 3,
|
||||
};
|
||||
|
||||
/* Helpers for parsing AVC NAL units. */
|
||||
|
||||
EXPORT const uint8_t *obs_avc_find_startcode(const uint8_t *p,
|
||||
|
|
Loading…
Reference in a new issue