static void mpy_eval_auto(Operand *op) { autoload_t *autl = op->value; y_errorq("mpy cannot autoload (symbol = %s), call require function", globalTable.names[autl->isymbol]); }
void yav_opencodec(yav_ctxt *obj, unsigned int width, unsigned int height) { obj->video_st->codec->width=width; obj->video_st->codec->height=height; av_dump_format(obj->oc, 0, obj->oc->filename, 1); if (obj->video_st) { AVCodecContext *c; c = obj->video_st->codec; if (avcodec_open2(c, obj->codec, NULL) < 0) y_error("could not open codec\n"); obj->picture = av_frame_alloc(); if (!obj->picture) y_error("Could not allocate picture"); int size = avpicture_get_size(c->pix_fmt, c->width, c->height); uint8_t *picture_buf = av_malloc(size); if (!picture_buf) { av_frame_free(&obj->picture); y_error("unable to allocate memory"); } avpicture_fill((AVPicture *)obj->picture, picture_buf, c->pix_fmt, c->width, c->height); if (obj->oc->oformat->video_codec == AV_CODEC_ID_H264 || obj->oc->oformat->video_codec == AV_CODEC_ID_THEORA) obj->picture->pts=-1; /* if the output format is not RGB24, then a temporary RGB24 picture is needed too. It is then converted to the required output format */ if (c->pix_fmt != AV_PIX_FMT_RGB24) { obj->tmp_picture = av_frame_alloc(); if (!obj->tmp_picture) { y_error("Could not allocate picture"); } size = avpicture_get_size(AV_PIX_FMT_RGB24, c->width, c->height); uint8_t *tmp_picture_buf = av_malloc(size); if (!tmp_picture_buf) { av_frame_free(&obj->tmp_picture); av_frame_free(&obj->picture); y_error("unable to allocate memory"); } avpicture_fill((AVPicture *)obj->tmp_picture, tmp_picture_buf, AV_PIX_FMT_RGB24, c->width, c->height); } } /* open the output file, if needed */ if (!(obj->oc->oformat->flags & AVFMT_NOFILE)) if (avio_open(&obj->oc->pb, obj->oc->filename, AVIO_FLAG_WRITE) < 0) y_errorq("Could not open '%s'", obj->oc->filename); obj->open = 1; /* write the stream header, if any */ avformat_write_header(obj->oc, NULL); }
static p_file * mpy_on_include(const char *filename, int fullparse) { mpy_fopen_t *f = 0; long len = 0; if (!mpy_parallel) return p_fopen(filename, "r"); /* refuse to reopen file for debug line numbers when parallel */ if (!fullparse) return 0; if (mpy_rank == 0) { p_file *file = p_fopen(filename, "r"); long sz = file? p_fsize(file) : 0; char *txt; long dims[2]; if (file) len = strlen(filename); dims[0] = 1; dims[1] = len + 1 + sz; ypush_check(1); /* may be called outside any interpreted function */ txt = ypush_c(dims); if (len) { strcpy(txt, filename); txt += len + 1; if (p_fread(file, txt, sz) != sz) { yarg_drop(1); y_errorq("rank 0 cannot read include file %s", filename); return 0; } } else { txt[0] = '\0'; } } mpy_bcast(1); /* broadcast top of stack to all ranks */ if (mpy_rank > 0) { /* set filename, file contents on all non-0 ranks */ long sz = 0; filename = ygeta_c(0, &sz, (long *)0); len = strlen(filename); } mpy_bcast(0); /* send acknowledgement back to rank 0 */ if (!len) return 0; f = p_malloc(sizeof(mpy_fopen_t)); f->ops = &mpy_fopen_ops; f->array = yget_use(0); f->addr = len + 1; yarg_drop(1); return (p_file *)f; }
int yarg_kw(int iarg, long *kglobs, int *kiargs) { long n, *globs, vndex; while (iarg>=0 && !sp[-iarg].ops) { if (!iarg) y_error("(BUG) stack corrupted in yarg_kw"); vndex = sp[-iarg].index; n = kglobs[0]; for (globs=kglobs+1 ; --n >= 0 ; globs++) if (globs[0] == vndex) break; if (n < 0) y_errorq("unrecognized keyword: %s", globalTable.names[vndex]); kiargs[kglobs[0]-1-n] = --iarg; --iarg; } return iarg; }