| 110 | } |
| 111 | |
| 112 | int main(int argc, char **argv) |
| 113 | { |
| 114 | PrivData pd; |
| 115 | DecodeContext dc; |
| 116 | |
| 117 | int width, height; |
| 118 | enum AVPixelFormat pix_fmt; |
| 119 | const char *filename; |
| 120 | int ret = 0; |
| 121 | |
| 122 | if (argc <= 4) { |
| 123 | fprintf(stderr, |
| 124 | "Usage: %s <input file> <dst width> <dst height> <dst pixfmt> [<random seed>] \n", |
| 125 | argv[0]); |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | memset(&pd, 0, sizeof(pd)); |
| 130 | |
| 131 | filename = argv[1]; |
| 132 | width = strtol(argv[2], NULL, 0); |
| 133 | height = strtol(argv[3], NULL, 0); |
| 134 | pix_fmt = av_get_pix_fmt(argv[4]); |
| 135 | |
| 136 | /* init RNG for generating slice sizes */ |
| 137 | if (argc >= 6) |
| 138 | pd.random_seed = strtoul(argv[5], NULL, 0); |
| 139 | else |
| 140 | pd.random_seed = av_get_random_seed(); |
| 141 | |
| 142 | av_lfg_init(&pd.lfg, pd.random_seed); |
| 143 | |
| 144 | av_pix_fmt_get_chroma_sub_sample(pix_fmt, &pd.h_shift_dst, &pd.v_shift_dst); |
| 145 | |
| 146 | /* allocate the frames for scaler output */ |
| 147 | for (int i = 0; i < 2; i++) { |
| 148 | AVFrame *frame = av_frame_alloc(); |
| 149 | if (!frame) { |
| 150 | fprintf(stderr, "Error allocating frames\n"); |
| 151 | return AVERROR(ENOMEM); |
| 152 | } |
| 153 | |
| 154 | frame->width = width; |
| 155 | frame->height = height; |
| 156 | frame->format = pix_fmt; |
| 157 | |
| 158 | ret = av_frame_get_buffer(frame, 0); |
| 159 | if (ret < 0) { |
| 160 | fprintf(stderr, "Error allocating frame data\n"); |
| 161 | return ret; |
| 162 | } |
| 163 | |
| 164 | /* make sure the padding is zeroed */ |
| 165 | for (int j = 0; j < 4 && frame->data[j]; j++) { |
| 166 | int shift = (j == 1 || j == 2) ? pd.v_shift_dst : 0; |
| 167 | memset(frame->data[j], 0, |
| 168 | frame->linesize[j] * (height >> shift)); |
| 169 | } |
nothing calls this directly
no test coverage detected