FFmpeg
Loading...
Searching...
No Matches
jpegapp.c File Reference
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/error.h"
#include "libavutil/file_open.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavcodec/bsf.h"
#include "libavcodec/bsf_internal.h"
#include "libavcodec/mjpeg.h"

Go to the source code of this file.

Data Structures

struct  JPEGAppContext
 

Macros

#define JPEGAPP_MAX_RECORD   (16 * 1024 * 1024)
 Sidecar format (big-endian), one record per encoded JPEG packet:
 
#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_BSF_PARAM)
 

Functions

static int jpeg_app_segment_len (const uint8_t *data, int size)
 
static int jpegapp_validate_payload (const uint8_t *data, int size)
 
static int jpegapp_init (AVBSFContext *ctx)
 
static void jpegapp_close (AVBSFContext *ctx)
 
static int jpegapp_read_record (AVBSFContext *ctx, int *out_size)
 
static int jpegapp_filter (AVBSFContext *ctx, AVPacket *out)
 

Variables

static const AVOption jpegapp_options []
 
static const AVClass jpegapp_class
 
static enum AVCodecID jpegapp_codec_ids []
 
const FFBitStreamFilter ff_jpegapp_bsf
 

Macro Definition Documentation

◆ JPEGAPP_MAX_RECORD

#define JPEGAPP_MAX_RECORD   (16 * 1024 * 1024)

Sidecar format (big-endian), one record per encoded JPEG packet:

u32be length u8 payload[length]

Payload is zero or more complete JPEG APP segments (APP0..APP15), each FF En + 16-bit length (length includes those two bytes). A zero length leaves the packet unchanged.

After SOI the payload is inserted. If it starts with APP0 and the two bytes immediately after SOI are an APP0 marker, that segment is dropped so the sidecar can replace it. An APP0 preceded by fill bytes or another segment is retained. An APP1-only payload keeps the encoder APP0: SOI, APP1, APP0, DQT, ...

A sidecar read or validation error stops further record consumption for this filter context. Flushing does not clear that error.

Definition at line 61 of file jpegapp.c.

Referenced by jpegapp_read_record().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 258 of file jpegapp.c.

◆ FLAGS

Definition at line 259 of file jpegapp.c.

Function Documentation

◆ jpeg_app_segment_len()

static int jpeg_app_segment_len ( const uint8_t * data,
int size )
static

Definition at line 73 of file jpegapp.c.

Referenced by jpegapp_filter(), and jpegapp_validate_payload().

◆ jpegapp_validate_payload()

static int jpegapp_validate_payload ( const uint8_t * data,
int size )
static

Definition at line 85 of file jpegapp.c.

Referenced by jpegapp_read_record().

◆ jpegapp_init()

static int jpegapp_init ( AVBSFContext * ctx)
static

Definition at line 98 of file jpegapp.c.

◆ jpegapp_close()

static void jpegapp_close ( AVBSFContext * ctx)
static

Definition at line 117 of file jpegapp.c.

◆ jpegapp_read_record()

static int jpegapp_read_record ( AVBSFContext * ctx,
int * out_size )
static

Definition at line 129 of file jpegapp.c.

Referenced by jpegapp_filter().

◆ jpegapp_filter()

static int jpegapp_filter ( AVBSFContext * ctx,
AVPacket * out )
static

Definition at line 190 of file jpegapp.c.

Variable Documentation

◆ jpegapp_options

const AVOption jpegapp_options[]
static
Initial value:
= {
{ "filename", "sidecar of u32be-length + APP-segment records", OFFSET(filename),
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "file", "sidecar of u32be-length + APP-segment records", OFFSET(filename),
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ NULL },
}
#define FLAGS
Definition cmdutils.c:596
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 260 of file jpegapp.c.

◆ jpegapp_class

const AVClass jpegapp_class
static
Initial value:
= {
.class_name = "jpegapp",
.item_name = av_default_item_name,
.option = jpegapp_options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
static const AVOption jpegapp_options[]
Definition jpegapp.c:260

Definition at line 268 of file jpegapp.c.

◆ jpegapp_codec_ids

enum AVCodecID jpegapp_codec_ids[]
static
Initial value:
= {
}
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57

Definition at line 275 of file jpegapp.c.

◆ ff_jpegapp_bsf

const FFBitStreamFilter ff_jpegapp_bsf
Initial value:
= {
.p.name = "jpegapp",
.p.codec_ids = jpegapp_codec_ids,
.p.priv_class = &jpegapp_class,
.priv_data_size = sizeof(JPEGAppContext),
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static int jpegapp_init(AVBSFContext *ctx)
Definition jpegapp.c:98
static int jpegapp_filter(AVBSFContext *ctx, AVPacket *out)
Definition jpegapp.c:190
static const AVClass jpegapp_class
Definition jpegapp.c:268
static enum AVCodecID jpegapp_codec_ids[]
Definition jpegapp.c:275
static void jpegapp_close(AVBSFContext *ctx)
Definition jpegapp.c:117
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29

Definition at line 279 of file jpegapp.c.