mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-09-19 12:56:40 +00:00
avcodec/roqvideo: Use void*, not AVCodecContext* for logctx
Also stop setting the field once per encode-frame. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
7d1401ed02
commit
08dd036b9f
@ -111,13 +111,13 @@ static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax
|
|||||||
/* check MV against frame boundaries */
|
/* check MV against frame boundaries */
|
||||||
if ((mx < 0) || (mx > ri->width - sz) ||
|
if ((mx < 0) || (mx > ri->width - sz) ||
|
||||||
(my < 0) || (my > ri->height - sz)) {
|
(my < 0) || (my > ri->height - sz)) {
|
||||||
av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
|
av_log(ri->logctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
|
||||||
mx, my, ri->width, ri->height);
|
mx, my, ri->width, ri->height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ri->last_frame->data[0]) {
|
if (!ri->last_frame->data[0]) {
|
||||||
av_log(ri->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
|
av_log(ri->logctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef AVCODEC_ROQVIDEO_H
|
#ifndef AVCODEC_ROQVIDEO_H
|
||||||
#define AVCODEC_ROQVIDEO_H
|
#define AVCODEC_ROQVIDEO_H
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "libavutil/frame.h"
|
||||||
|
|
||||||
typedef struct roq_cell {
|
typedef struct roq_cell {
|
||||||
unsigned char y[4];
|
unsigned char y[4];
|
||||||
@ -39,7 +39,7 @@ typedef struct motion_vect {
|
|||||||
|
|
||||||
typedef struct RoqContext {
|
typedef struct RoqContext {
|
||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
AVCodecContext *avctx;
|
void *logctx;
|
||||||
AVFrame *last_frame;
|
AVFrame *last_frame;
|
||||||
AVFrame *current_frame;
|
AVFrame *current_frame;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -72,7 +72,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
|
|||||||
xpos = ypos = 0;
|
xpos = ypos = 0;
|
||||||
|
|
||||||
if (chunk_size > bytestream2_get_bytes_left(gb)) {
|
if (chunk_size > bytestream2_get_bytes_left(gb)) {
|
||||||
av_log(ri->avctx, AV_LOG_ERROR, "Chunk does not fit in input buffer\n");
|
av_log(ri->logctx, AV_LOG_ERROR, "Chunk does not fit in input buffer\n");
|
||||||
chunk_size = bytestream2_get_bytes_left(gb);
|
chunk_size = bytestream2_get_bytes_left(gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
|
|||||||
for (yp = ypos; yp < ypos + 16; yp += 8)
|
for (yp = ypos; yp < ypos + 16; yp += 8)
|
||||||
for (xp = xpos; xp < xpos + 16; xp += 8) {
|
for (xp = xpos; xp < xpos + 16; xp += 8) {
|
||||||
if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
|
if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
|
||||||
av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");
|
av_log(ri->logctx, AV_LOG_VERBOSE, "Chunk is too short\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (vqflg_pos < 0) {
|
if (vqflg_pos < 0) {
|
||||||
@ -114,7 +114,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
|
|||||||
if(k & 0x02) y += 4;
|
if(k & 0x02) y += 4;
|
||||||
|
|
||||||
if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
|
if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
|
||||||
av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");
|
av_log(ri->logctx, AV_LOG_VERBOSE, "Chunk is too short\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (vqflg_pos < 0) {
|
if (vqflg_pos < 0) {
|
||||||
@ -169,7 +169,7 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
RoqContext *s = avctx->priv_data;
|
RoqContext *s = avctx->priv_data;
|
||||||
|
|
||||||
s->avctx = avctx;
|
s->logctx = avctx;
|
||||||
|
|
||||||
if (avctx->width % 16 || avctx->height % 16) {
|
if (avctx->width % 16 || avctx->height % 16) {
|
||||||
avpriv_request_sample(avctx, "Dimensions not being a multiple of 16");
|
avpriv_request_sample(avctx, "Dimensions not being a multiple of 16");
|
||||||
|
@ -911,10 +911,10 @@ static int roq_encode_video(RoqEncContext *enc)
|
|||||||
/* Quake 3 can't handle chunks bigger than 65535 bytes */
|
/* Quake 3 can't handle chunks bigger than 65535 bytes */
|
||||||
if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
|
if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
|
||||||
if (enc->lambda > 100000) {
|
if (enc->lambda > 100000) {
|
||||||
av_log(roq->avctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");
|
av_log(roq->logctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
av_log(roq->avctx, AV_LOG_ERROR,
|
av_log(roq->logctx, AV_LOG_ERROR,
|
||||||
"Warning, generated a frame too big for Quake (%d > 65535), "
|
"Warning, generated a frame too big for Quake (%d > 65535), "
|
||||||
"now switching to a bigger qscale value.\n",
|
"now switching to a bigger qscale value.\n",
|
||||||
tempData->mainChunkSize/8);
|
tempData->mainChunkSize/8);
|
||||||
@ -972,7 +972,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
av_lfg_init(&enc->randctx, 1);
|
av_lfg_init(&enc->randctx, 1);
|
||||||
|
|
||||||
roq->avctx = avctx;
|
roq->logctx = avctx;
|
||||||
|
|
||||||
enc->framesSinceKeyframe = 0;
|
enc->framesSinceKeyframe = 0;
|
||||||
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
|
if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
|
||||||
@ -1057,8 +1057,6 @@ static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
RoqContext *const roq = &enc->common;
|
RoqContext *const roq = &enc->common;
|
||||||
int size, ret;
|
int size, ret;
|
||||||
|
|
||||||
roq->avctx = avctx;
|
|
||||||
|
|
||||||
enc->frame_to_enc = frame;
|
enc->frame_to_enc = frame;
|
||||||
|
|
||||||
if (frame->quality)
|
if (frame->quality)
|
||||||
|
Loading…
Reference in New Issue
Block a user