Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
jpeg_marker_guard.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/** @file jpeg_marker_guard.h
19 * @brief Reject invalid Huffman selectors before the bundled codec indexes its tables. */
20#ifndef USHER_JPEG_MARKER_GUARD_H
21#define USHER_JPEG_MARKER_GUARD_H
22
23#include <stddef.h>
24#include <stdio.h>
25#include <jpeglib.h>
26#include <jerror.h>
27
28/** @brief Validate marker parameters from an error manager's emit_message callback. */
29static inline void usher_jpeg_validate_marker(j_common_ptr state)
30{
31 if (!state->is_decompressor) return;
32 if (state->err->msg_code == JTRC_DHT) {
33 const int index = state->err->msg_parm.i[0];
34 if (index < 0 || (index & ~0x10) >= NUM_HUFF_TBLS) ERREXIT1(state, JERR_DHT_INDEX, index);
35 } else if (state->err->msg_code == JTRC_SOS_COMPONENT && !((j_decompress_ptr)state)->arith_code) {
36 const int *selectors = state->err->msg_parm.i;
37 if (selectors[1] < 0 || selectors[1] >= NUM_HUFF_TBLS ||
38 selectors[2] < 0 || selectors[2] >= NUM_HUFF_TBLS) ERREXIT(state, JERR_BAD_HUFF_TABLE);
39 }
40}
41
42#endif
static void usher_jpeg_validate_marker(j_common_ptr state)
Validate marker parameters from an error manager's emit_message callback.