History

avcodec/roqvideo: Use void*, not AVCodecContext* for logctx

Also stop setting the field once per encode-frame.

Andreas Rheinhardt committed 3 years ago

Commit 08dd0361 parent 7d1401e4 files · +11 −13Browse files

Unified · Split

4 files
  1. libavcodec/roqvideo.c +2 −2
  2. libavcodec/roqvideo.h +2 −2
  3. libavcodec/roqvideodec.c +4 −4
  4. libavcodec/roqvideoenc.c +3 −5
libavcodec/roqvideo.c+2−2
@@ -111,13 +111,13 @@ static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax · 110 unmodified lines
111 /* check MV against frame boundaries */111 /* check MV against frame boundaries */
112 if ((mx < 0) || (mx > ri->width - sz) ||112 if ((mx < 0) || (mx > ri->width - sz) ||
113 (my < 0) || (my > ri->height - sz)) {113 (my < 0) || (my > ri->height - sz)) {
114 av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",114 av_log(ri->logctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
115 mx, my, ri->width, ri->height);115 mx, my, ri->width, ri->height);
116 return;116 return;
117 }117 }
118 118
119 if (!ri->last_frame->data[0]) {119 if (!ri->last_frame->data[0]) {
120 av_log(ri->avctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");120 av_log(ri->logctx, AV_LOG_ERROR, "Invalid decode type. Invalid header?\n");
121 return;121 return;
122 }122 }
123 123
libavcodec/roqvideo.h+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
22#ifndef AVCODEC_ROQVIDEO_H22#ifndef AVCODEC_ROQVIDEO_H
23#define AVCODEC_ROQVIDEO_H23#define AVCODEC_ROQVIDEO_H
24 24
25#include "avcodec.h"25#include "libavutil/frame.h"
26 26
27typedef struct roq_cell {27typedef struct roq_cell {
28 unsigned char y[4];28 unsigned char y[4];
@@ -39,7 +39,7 @@ typedef struct motion_vect { · 10 unmodified lines
39 39
40typedef struct RoqContext {40typedef struct RoqContext {
41 const AVClass *class;41 const AVClass *class;
42 AVCodecContext *avctx;42 void *logctx;
43 AVFrame *last_frame;43 AVFrame *last_frame;
44 AVFrame *current_frame;44 AVFrame *current_frame;
45 int width, height;45 int width, height;
libavcodec/roqvideodec.c+4−4
@@ -72,7 +72,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb) · 71 unmodified lines
72 xpos = ypos = 0;72 xpos = ypos = 0;
73 73
74 if (chunk_size > bytestream2_get_bytes_left(gb)) {74 if (chunk_size > bytestream2_get_bytes_left(gb)) {
75 av_log(ri->avctx, AV_LOG_ERROR, "Chunk does not fit in input buffer\n");75 av_log(ri->logctx, AV_LOG_ERROR, "Chunk does not fit in input buffer\n");
76 chunk_size = bytestream2_get_bytes_left(gb);76 chunk_size = bytestream2_get_bytes_left(gb);
77 }77 }
78 78
@@ -80,7 +80,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb) · 1 unmodified line
80 for (yp = ypos; yp < ypos + 16; yp += 8)80 for (yp = ypos; yp < ypos + 16; yp += 8)
81 for (xp = xpos; xp < xpos + 16; xp += 8) {81 for (xp = xpos; xp < xpos + 16; xp += 8) {
82 if (bytestream2_tell(gb) >= chunk_start + chunk_size) {82 if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
83 av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");83 av_log(ri->logctx, AV_LOG_VERBOSE, "Chunk is too short\n");
84 return;84 return;
85 }85 }
86 if (vqflg_pos < 0) {86 if (vqflg_pos < 0) {
@@ -114,7 +114,7 @@ static void roqvideo_decode_frame(RoqContext *ri, GetByteContext *gb) · 27 unmodified lines
114 if(k & 0x02) y += 4;114 if(k & 0x02) y += 4;
115 115
116 if (bytestream2_tell(gb) >= chunk_start + chunk_size) {116 if (bytestream2_tell(gb) >= chunk_start + chunk_size) {
117 av_log(ri->avctx, AV_LOG_VERBOSE, "Chunk is too short\n");117 av_log(ri->logctx, AV_LOG_VERBOSE, "Chunk is too short\n");
118 return;118 return;
119 }119 }
120 if (vqflg_pos < 0) {120 if (vqflg_pos < 0) {
@@ -169,7 +169,7 @@ static av_cold int roq_decode_init(AVCodecContext *avctx) · 48 unmodified lines
169{169{
170 RoqContext *s = avctx->priv_data;170 RoqContext *s = avctx->priv_data;
171 171
172 s->avctx = avctx;172 s->logctx = avctx;
173 173
174 if (avctx->width % 16 || avctx->height % 16) {174 if (avctx->width % 16 || avctx->height % 16) {
175 avpriv_request_sample(avctx, "Dimensions not being a multiple of 16");175 avpriv_request_sample(avctx, "Dimensions not being a multiple of 16");
libavcodec/roqvideoenc.c+3−5
@@ -911,10 +911,10 @@ static int roq_encode_video(RoqEncContext *enc) · 910 unmodified lines
911 /* Quake 3 can't handle chunks bigger than 65535 bytes */911 /* Quake 3 can't handle chunks bigger than 65535 bytes */
912 if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {912 if (tempData->mainChunkSize/8 > 65535 && enc->quake3_compat) {
913 if (enc->lambda > 100000) {913 if (enc->lambda > 100000) {
914 av_log(roq->avctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");914 av_log(roq->logctx, AV_LOG_ERROR, "Cannot encode video in Quake compatible form\n");
915 return AVERROR(EINVAL);915 return AVERROR(EINVAL);
916 }916 }
917 av_log(roq->avctx, AV_LOG_ERROR,917 av_log(roq->logctx, AV_LOG_ERROR,
918 "Warning, generated a frame too big for Quake (%d > 65535), "918 "Warning, generated a frame too big for Quake (%d > 65535), "
919 "now switching to a bigger qscale value.\n",919 "now switching to a bigger qscale value.\n",
920 tempData->mainChunkSize/8);920 tempData->mainChunkSize/8);
@@ -972,7 +972,7 @@ static av_cold int roq_encode_init(AVCodecContext *avctx) · 51 unmodified lines
972 972
973 av_lfg_init(&enc->randctx, 1);973 av_lfg_init(&enc->randctx, 1);
974 974
975 roq->avctx = avctx;975 roq->logctx = avctx;
976 976
977 enc->framesSinceKeyframe = 0;977 enc->framesSinceKeyframe = 0;
978 if ((avctx->width & 0xf) || (avctx->height & 0xf)) {978 if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
@@ -1057,8 +1057,6 @@ static int roq_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 78 unmodified lines
1057 RoqContext *const roq = &enc->common;1057 RoqContext *const roq = &enc->common;
1058 int size, ret;1058 int size, ret;
1059 1059
1060 roq->avctx = avctx;
1061
1062 enc->frame_to_enc = frame;1060 enc->frame_to_enc = frame;
1063 1061
1064 if (frame->quality)1062 if (frame->quality)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t