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>
pull/390/head
Andreas Rheinhardt 1 year ago
parent 7d1401ed02
commit 08dd036b9f
  1. 4
      libavcodec/roqvideo.c
  2. 4
      libavcodec/roqvideo.h
  3. 8
      libavcodec/roqvideodec.c
  4. 8
      libavcodec/roqvideoenc.c

@ -111,13 +111,13 @@ static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax
/* check MV against frame boundaries */
if ((mx < 0) || (mx > ri->width - 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);
return;
}
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;
}

@ -22,7 +22,7 @@
#ifndef AVCODEC_ROQVIDEO_H
#define AVCODEC_ROQVIDEO_H
#include "avcodec.h"
#include "libavutil/frame.h"
typedef struct roq_cell {
unsigned char y[4];
@ -39,7 +39,7 @@ typedef struct motion_vect {
typedef struct RoqContext {
const AVClass *class;
AVCodecContext *avctx;
void *logctx;
AVFrame *last_frame;
AVFrame *current_frame;
int width, height;

@ -72,7 +72,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
xpos = ypos = 0;
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);
}
@ -80,7 +80,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
for (yp = ypos; yp < ypos + 16; yp += 8)
for (xp = xpos; xp < xpos + 16; xp += 8) {
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;
}
if (vqflg_pos < 0) {
@ -114,7 +114,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb)
if(k & 0x02) y += 4;
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;
}
if (vqflg_pos < 0) {
@ -169,7 +169,7 @@ static av_cold int roq_decode_init(AVCodecContext *avctx)
{
RoqContext *s = avctx->priv_data;
s->avctx = avctx;
s->logctx = avctx;
if (avctx->width % 16 || avctx->height % 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 */
if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
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);
}
av_log(roq->avctx, AV_LOG_ERROR,
av_log(roq->logctx, AV_LOG_ERROR,
"Warning, generated a frame too big for Quake (%d > 65535), "
"now switching to a bigger qscale value.\n",
tempData->mainChunkSize/8);
@ -972,7 +972,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx)
av_lfg_init(&enc->randctx, 1);
roq->avctx = avctx;
roq->logctx = avctx;
enc->framesSinceKeyframe = 0;
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;
int size, ret;
roq->avctx = avctx;
enc->frame_to_enc = frame;
if (frame->quality)

Loading…
Cancel
Save