From 7586cae160b47809034db5313bcafeee02eae627 Mon Sep 17 00:00:00 2001 From: aggresss Date: Sat, 18 Nov 2023 13:50:46 +0800 Subject: [PATCH] 2023-11-18 13:50:46 CST W46D6 --- avcodec.go | 11 ++- avdevice.go | 3 - avfilter.go | 9 -- avformat.go | 16 +--- avformat_avio.go | 146 +++++++++++++++++++++++++++-- avutil_frame.go | 6 -- avutil_opt.go | 3 - examples/decode-audio/main.go | 4 +- examples/decode-video/main.go | 4 +- examples/demuxing-decoding/main.go | 4 +- examples/encode-audio/main.go | 2 +- examples/encode-video/main.go | 2 +- examples/hw-decode/main.go | 2 +- examples/resampling-audio/main.go | 2 +- examples/scaling-video/main.go | 2 +- examples/vaapi-encode/main.go | 4 +- 16 files changed, 158 insertions(+), 62 deletions(-) diff --git a/avcodec.go b/avcodec.go index 1173fca..1740732 100644 --- a/avcodec.go +++ b/avcodec.go @@ -3086,6 +3086,10 @@ func (avctx *AVCodecContext) GetLevelAddr() *int32 { return (*int32)(&avctx.level) } +const ( + FF_LEVEL_UNKNOWN = int32(C.FF_LEVEL_UNKNOWN) +) + // GetSkipLoopFilter gets `AVCodecContext.skip_loop_filter` value. func (avctx *AVCodecContext) GetSkipLoopFilter() AVDiscard { return (AVDiscard)(avctx.skip_loop_filter) @@ -3478,8 +3482,8 @@ const ( ) // GetCodedSideData gets `AVCodecContext.coded_side_data` value. -func (avctx *AVCodecContext) GetCodedSideData() *AVPacketSideData { - return (*AVPacketSideData)(avctx.coded_side_data) +func (avctx *AVCodecContext) GetCodedSideData() []AVPacketSideData { + return unsafe.Slice((*AVPacketSideData)(avctx.coded_side_data), avctx.nb_coded_side_data) } // SetCodedSideData sets `AVCodecContext.coded_side_data` value. @@ -4152,9 +4156,6 @@ func (sbt *AVSubtitle) GetNumRectsAddr() *uint32 { // GetRects gets `AVSubtitle.rects` value. func (sbt *AVSubtitle) GetRects() []*AVSubtitleRect { - if sbt.rects == nil { - return nil - } return unsafe.Slice((**AVSubtitleRect)(unsafe.Pointer(sbt.rects)), sbt.num_rects) } diff --git a/avdevice.go b/avdevice.go index 81a158b..79fb0eb 100644 --- a/avdevice.go +++ b/avdevice.go @@ -397,9 +397,6 @@ type AVDeviceInfoList C.struct_AVDeviceInfoList // GetDevices gets `AVDeviceInfoList.devices` value. func (dcl *AVDeviceInfoList) GetDevices() []*AVDeviceInfo { - if dcl.devices == nil { - return nil - } return unsafe.Slice((**AVDeviceInfo)(unsafe.Pointer(dcl.devices)), dcl.nb_devices) } diff --git a/avfilter.go b/avfilter.go index b1e79b6..6a428ca 100644 --- a/avfilter.go +++ b/avfilter.go @@ -201,9 +201,6 @@ func (fltc *AVFilterContext) GetInputPadsAddr() **AVFilterPad { // GetInputs gets `AVFilterContext.inputs` value. func (fltc *AVFilterContext) GetInputs() []*AVFilterLink { - if fltc.inputs == nil { - return nil - } return unsafe.Slice((**AVFilterLink)(unsafe.Pointer(fltc.inputs)), fltc.nb_inputs) } @@ -249,9 +246,6 @@ func (fltc *AVFilterContext) GetOutputPadsAddr() **AVFilterPad { // GetOutputs gets `AVFilterContext.outputs` value. func (fltc *AVFilterContext) GetOutputs() []*AVFilterLink { - if fltc.outputs == nil { - return nil - } return unsafe.Slice((**AVFilterLink)(unsafe.Pointer(fltc.outputs)), fltc.nb_outputs) } @@ -845,9 +839,6 @@ func (fltg *AVFilterGraph) GetAvClassAddr() **AVClass { // GetFilters gets `AVFilterGraph.filters` value. func (fltg *AVFilterGraph) GetFilters() []*AVFilterContext { - if fltg.filters == nil { - return nil - } return unsafe.Slice((**AVFilterContext)(unsafe.Pointer(fltg.filters)), fltg.nb_filters) } diff --git a/avformat.go b/avformat.go index f252f9a..0503956 100644 --- a/avformat.go +++ b/avformat.go @@ -612,8 +612,8 @@ func (stm *AVStream) GetAttachedPicAddr() *AVPacket { } // GetSideData gets `AVStream.side_data` value. -func (stm *AVStream) GetSideData() *AVPacketSideData { - return (*AVPacketSideData)(stm.side_data) +func (stm *AVStream) GetSideData() []AVPacketSideData { + return unsafe.Slice((*AVPacketSideData)(stm.side_data), stm.nb_side_data) } // SetSideData sets `AVStream.side_data` value. @@ -793,9 +793,6 @@ func (pgm *AVProgram) GetDiscardAddr() *AVDiscard { // GetStreamIndex gets `AVProgram.stream_index` value. func (pgm *AVProgram) GetStreamIndex() (v []uint32) { - if pgm.stream_index == nil { - return v - } return unsafe.Slice((*uint32)(unsafe.Pointer(pgm.stream_index)), pgm.nb_stream_indexes) } @@ -1113,9 +1110,6 @@ func (s *AVFormatContext) GetNbStreamsAddr() *uint32 { // GetStreams gets `AVFormatContext.streams` value. func (s *AVFormatContext) GetStreams() (v []*AVStream) { - if s.streams == nil { - return v - } return unsafe.Slice((**AVStream)(unsafe.Pointer(s.streams)), s.nb_streams) } @@ -1317,9 +1311,6 @@ func (s *AVFormatContext) GetNbProgramsAddr() *uint32 { // GetPrograms gets `AVFormatContext.programs` value. func (s *AVFormatContext) GetPrograms() (v []*AVProgram) { - if s.programs == nil { - return v - } return unsafe.Slice((**AVProgram)(unsafe.Pointer(s.programs)), s.nb_programs) } @@ -1425,9 +1416,6 @@ func (s *AVFormatContext) GetNbChaptersAddr() *uint32 { // GetChapters gets `AVFormatContext.chapters` value. func (s *AVFormatContext) GetChapters() (v []*AVChapter) { - if s.chapters == nil { - return v - } return unsafe.Slice((**AVChapter)(unsafe.Pointer(s.chapters)), s.nb_chapters) } diff --git a/avformat_avio.go b/avformat_avio.go index 571617c..bec7f3a 100644 --- a/avformat_avio.go +++ b/avformat_avio.go @@ -8,9 +8,17 @@ package ffmpeg #include typedef int (*avio_interrupt_callback_func)(void* opaque); + typedef int (*avio_context_read_packet_func)(void *opaque, uint8_t *buf, int buf_size); typedef int (*avio_context_write_packet_func)(void *opaque, uint8_t *buf, int buf_size); typedef int64_t (*avio_context_seek_func)(void *opaque, int64_t offset, int whence); +typedef unsigned long (*avio_context_update_checksum)(unsigned long checksum, + const uint8_t *buf, unsigned int size); +typedef int (*avio_context_read_pause)(void *opaque, int pause); +typedef int64_t (*avio_context_read_seek)(void *opaque, int stream_index, + int64_t timestamp, int flags); +typedef int (*avio_context_write_data_type)(void *opaque, uint8_t *buf, int buf_size, + enum AVIODataMarkerType type, int64_t time); int avio_printf_wrap(AVIOContext *s, const char *fmt) { return avio_printf(s, fmt, NULL); @@ -259,6 +267,30 @@ const ( // AVIOContext type AVIOContext C.struct_AVIOContext +// typedef int (*avio_context_read_packet_func)(void *opaque, uint8_t *buf, int buf_size); +type AVIOContextReadPacketFunc = C.avio_context_read_packet_func + +// typedef int (*avio_context_write_packet_func)(void *opaque, uint8_t *buf, int buf_size); +type AVIOContextWritePacketFunc = C.avio_context_write_packet_func + +// typedef int64_t (*avio_context_seek_func)(void *opaque, int64_t offset, int whence); +type AVIOContextSeekFunc = C.avio_context_seek_func + +// typedef unsigned long (*avio_context_update_checksum)(unsigned long checksum, +// const uint8_t *buf, unsigned int size); +type AVIOContextUpdateChecksum = C.avio_context_update_checksum + +// typedef int (*avio_context_read_pause)(void *opaque, int pause); +type AVIOContextReadPause = C.avio_context_read_pause + +// typedef int64_t (*avio_context_read_seek)(void *opaque, int stream_index, +// int64_t timestamp, int flags); +type AVIOContextReadSeek = C.avio_context_read_seek + +// typedef int (*avio_context_write_data_type)(void *opaque, uint8_t *buf, int buf_size, +// enum AVIODataMarkerType type, int64_t time); +type AVIOContextWriteDataType = C.avio_context_write_data_type + // GetAvClass gets `AVIOContext.av_class` value. func (ctx *AVIOContext) GetAvClass() *AVClass { return (*AVClass)(ctx.av_class) @@ -349,6 +381,51 @@ func (ctx *AVIOContext) GetOpaqueAddr() *unsafe.Pointer { return (*unsafe.Pointer)(&ctx.opaque) } +// GetReadPacket gets `AVIOContext.read_packet` value. +func (ctx *AVIOContext) GetReadPacket() AVIOContextReadPacketFunc { + return (AVIOContextReadPacketFunc)(ctx.read_packet) +} + +// SetReadPacket sets `AVIOContext.read_packet` value. +func (ctx *AVIOContext) SetReadPacket(v AVIOContextReadPacketFunc) { + ctx.read_packet = (C.avio_context_read_packet_func)(v) +} + +// GetReadPacketAddr gets `AVIOContext.read_packet` address. +func (ctx *AVIOContext) GetReadPacketAddr() *AVIOContextReadPacketFunc { + return (*AVIOContextReadPacketFunc)(&ctx.read_packet) +} + +// GetWritePacket gets `AVIOContext.write_packet` value. +func (ctx *AVIOContext) GetWritePacket() AVIOContextWritePacketFunc { + return (AVIOContextWritePacketFunc)(ctx.write_packet) +} + +// SetWritePacket sets `AVIOContext.write_packet` value. +func (ctx *AVIOContext) SetWritePacket(v AVIOContextWritePacketFunc) { + ctx.write_packet = (C.avio_context_write_packet_func)(v) +} + +// GetWritePacketAddr gets `AVIOContext.write_packet` address. +func (ctx *AVIOContext) GetWritePacketAddr() *AVIOContextWritePacketFunc { + return (*AVIOContextWritePacketFunc)(&ctx.write_packet) +} + +// GetSeek gets `AVIOContext.seek` value. +func (ctx *AVIOContext) GetSeek() AVIOContextSeekFunc { + return (AVIOContextSeekFunc)(ctx.seek) +} + +// SetSeek sets `AVIOContext.seek` value. +func (ctx *AVIOContext) SetSeek(v AVIOContextSeekFunc) { + ctx.seek = (C.avio_context_seek_func)(v) +} + +// GetSeekAddr gets `AVIOContext.seek` address. +func (ctx *AVIOContext) GetSeekAddr() *AVIOContextSeekFunc { + return (*AVIOContextSeekFunc)(&ctx.seek) +} + // GetPos gets `AVIOContext.pos` value. func (ctx *AVIOContext) GetPos() int64 { return (int64)(ctx.pos) @@ -439,6 +516,51 @@ func (ctx *AVIOContext) GetChecksumPtrAddr() **uint8 { return (**uint8)(unsafe.Pointer(&ctx.checksum_ptr)) } +// GetUpdateChecksum gets `AVIOContext.update_checksum` value. +func (ctx *AVIOContext) GetUpdateChecksum() AVIOContextUpdateChecksum { + return (AVIOContextUpdateChecksum)(ctx.update_checksum) +} + +// SetUpdateChecksum sets `AVIOContext.update_checksum` value. +func (ctx *AVIOContext) SetUpdateChecksum(v AVIOContextUpdateChecksum) { + ctx.update_checksum = (C.avio_context_update_checksum)(v) +} + +// GetUpdateChecksumAddr gets `AVIOContext.update_checksum` address. +func (ctx *AVIOContext) GetUpdateChecksumAddr() *AVIOContextUpdateChecksum { + return (*AVIOContextUpdateChecksum)(&ctx.update_checksum) +} + +// GetReadPause gets `AVIOContext.read_pause` value. +func (ctx *AVIOContext) GetReadPause() AVIOContextReadPause { + return (AVIOContextReadPause)(ctx.read_pause) +} + +// SetReadPause sets `AVIOContext.read_pause` value. +func (ctx *AVIOContext) SetReadPause(v AVIOContextReadPause) { + ctx.read_pause = (C.avio_context_read_pause)(v) +} + +// GetReadPauseAddr gets `AVIOContext.read_pause` address. +func (ctx *AVIOContext) GetReadPauseAddr() *AVIOContextReadPause { + return (*AVIOContextReadPause)(&ctx.read_pause) +} + +// GetReadSeek gets `AVIOContext.read_seek` value. +func (ctx *AVIOContext) GetReadSeek() AVIOContextReadSeek { + return (AVIOContextReadSeek)(ctx.read_seek) +} + +// SetReadSeek sets `AVIOContext.read_seek` value. +func (ctx *AVIOContext) SetReadSeek(v AVIOContextReadSeek) { + ctx.read_seek = (C.avio_context_read_seek)(v) +} + +// GetReadSeekAddr gets `AVIOContext.read_seek` address. +func (ctx *AVIOContext) GetReadSeekAddr() *AVIOContextReadSeek { + return (*AVIOContextReadSeek)(&ctx.read_seek) +} + // GetError gets `AVIOContext.error` value. func (ctx *AVIOContext) GetError() int32 { return (int32)(ctx.error) @@ -584,6 +706,21 @@ func (ctx *AVIOContext) GetProtocolBlacklist() string { return C.GoString(ctx.protocol_blacklist) } +// GetWriteDataType gets `AVIOContext.write_data_type` value. +func (ctx *AVIOContext) GetWriteDataType() AVIOContextWriteDataType { + return (AVIOContextWriteDataType)(ctx.write_data_type) +} + +// SetWriteDataType sets `AVIOContext.write_data_type` value. +func (ctx *AVIOContext) SetWriteDataType(v AVIOContextWriteDataType) { + ctx.write_data_type = (C.avio_context_write_data_type)(v) +} + +// GetWriteDataTypeAddr gets `AVIOContext.write_data_type` address. +func (ctx *AVIOContext) GetWriteDataTypeAddr() *AVIOContextWriteDataType { + return (*AVIOContextWriteDataType)(&ctx.write_data_type) +} + // GetIgnoreBoundaryPoint gets `AVIOContext.ignore_boundary_point` value. func (ctx *AVIOContext) GetIgnoreBoundaryPoint() int32 { return (int32)(ctx.ignore_boundary_point) @@ -731,15 +868,6 @@ func AvIOFreeDirectoryEntry(entry **AVIODirEntry) { C.avio_free_directory_entry((**C.struct_AVIODirEntry)(unsafe.Pointer(entry))) } -// typedef int (*avio_context_read_packet_func)(void *opaque, uint8_t *buf, int buf_size); -type AVIOContextReadPacketFunc = C.avio_context_read_packet_func - -// typedef int (*avio_context_write_packet_func)(void *opaque, uint8_t *buf, int buf_size); -type AVIOContextWritePacketFunc = C.avio_context_write_packet_func - -// typedef int64_t (*avio_context_seek_func)(void *opaque, int64_t offset, int whence); -type AVIOContextSeekFunc = C.avio_context_seek_func - // AvIOAllocContext sllocates and initialize an AVIOContext for buffered I/O. It must be later // freed with AVIOContextFree(). func AvIOAllocContext(buffer *uint8, bufferSize, writeFlag int32, diff --git a/avutil_frame.go b/avutil_frame.go index 9e93ab7..1a16585 100644 --- a/avutil_frame.go +++ b/avutil_frame.go @@ -628,9 +628,6 @@ func (frame *AVFrame) GetBufAddr() ***AVBufferRef { // GetExtendedBuf gets `AVFrame.extended_buf` value. func (frame *AVFrame) GetExtendedBuf() []*AVBufferRef { - if frame.extended_buf == nil { - return nil - } return unsafe.Slice((**AVBufferRef)(unsafe.Pointer(frame.extended_buf)), frame.nb_extended_buf) } @@ -662,9 +659,6 @@ func (frame *AVFrame) GetNbExtendedBufAddr() *int32 { // GetSideData gets `AVFrame.side_data` value. func (frame *AVFrame) GetSideData() []*AVFrameSideData { - if frame.side_data == nil { - return nil - } return unsafe.Slice((**AVFrameSideData)(unsafe.Pointer(frame.side_data)), frame.nb_side_data) } diff --git a/avutil_opt.go b/avutil_opt.go index 7b2fa1b..8c836b6 100644 --- a/avutil_opt.go +++ b/avutil_opt.go @@ -346,9 +346,6 @@ type AVOptionRanges C.struct_AVOptionRanges // GetRange gets `AVOptionRanges.range` value. func (optrs *AVOptionRanges) GetRange() []*AVOptionRange { - if optrs._range == nil { - return nil - } return unsafe.Slice((**AVOptionRange)(unsafe.Pointer(optrs._range)), optrs.nb_components*optrs.nb_ranges) } diff --git a/examples/decode-audio/main.go b/examples/decode-audio/main.go index 4dc7b47..9d98fa0 100644 --- a/examples/decode-audio/main.go +++ b/examples/decode-audio/main.go @@ -103,12 +103,12 @@ func main() { os.Exit(1) } - f, err := os.OpenFile(filename, os.O_RDONLY, 0666) + f, err := os.OpenFile(filename, os.O_RDONLY, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", filename) os.Exit(1) } - outfile, err := os.OpenFile(outfilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + outfile, err := os.OpenFile(outfilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", outfilename) os.Exit(1) diff --git a/examples/decode-video/main.go b/examples/decode-video/main.go index a1ea846..825d95e 100644 --- a/examples/decode-video/main.go +++ b/examples/decode-video/main.go @@ -15,7 +15,7 @@ const ( ) func pgmSave(buf *uint8, wrap, xsize, ysize int32, filename string) { - f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) fmt.Fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255) bufSlice := unsafe.Slice(buf, xsize*ysize) for i := int32(0); i < ysize; i++ { @@ -90,7 +90,7 @@ func main() { inbuf := make([]byte, INBUF_SIZE+ffmpeg.AV_INPUT_BUFFER_PADDING_SIZE) - f, err := os.OpenFile(filename, os.O_RDONLY, 0666) + f, err := os.OpenFile(filename, os.O_RDONLY, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", filename) os.Exit(1) diff --git a/examples/demuxing-decoding/main.go b/examples/demuxing-decoding/main.go index afdac64..452836a 100644 --- a/examples/demuxing-decoding/main.go +++ b/examples/demuxing-decoding/main.go @@ -214,7 +214,7 @@ func main() { if videoStreamIdx, videoDecCtx, ret = openCodecContext(fmtCtx, ffmpeg.AVMEDIA_TYPE_VIDEO); ret >= 0 { videoStream = fmtCtx.GetStreams()[videoStreamIdx] - videoDstFile, err = os.OpenFile(videoDstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + videoDstFile, err = os.OpenFile(videoDstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open destination file %s\n", videoDstFilename) ret = 1 @@ -239,7 +239,7 @@ func main() { if audioStreamIdx, audioDecCtx, ret = openCodecContext(fmtCtx, ffmpeg.AVMEDIA_TYPE_AUDIO); ret >= 0 { audioStream = fmtCtx.GetStreams()[audioStreamIdx] - audioDstFile, err = os.OpenFile(audioDstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + audioDstFile, err = os.OpenFile(audioDstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open destination file %s\n", audioDstFilename) ret = 1 diff --git a/examples/encode-audio/main.go b/examples/encode-audio/main.go index 202b897..b890e55 100644 --- a/examples/encode-audio/main.go +++ b/examples/encode-audio/main.go @@ -120,7 +120,7 @@ func main() { os.Exit(1) } - f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", filename) os.Exit(1) diff --git a/examples/encode-video/main.go b/examples/encode-video/main.go index 9e741ab..0fe51b5 100644 --- a/examples/encode-video/main.go +++ b/examples/encode-video/main.go @@ -90,7 +90,7 @@ func main() { os.Exit(1) } - f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", filename) os.Exit(1) diff --git a/examples/hw-decode/main.go b/examples/hw-decode/main.go index 377f1a1..6d1222b 100644 --- a/examples/hw-decode/main.go +++ b/examples/hw-decode/main.go @@ -210,7 +210,7 @@ func main() { } // open the file to dump raw data - outputFile, _ = os.OpenFile(os.Args[3], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + outputFile, _ = os.OpenFile(os.Args[3], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) // actual decoding and dump the raw data for ret >= 0 { diff --git a/examples/resampling-audio/main.go b/examples/resampling-audio/main.go index ef9d58f..9aaa096 100644 --- a/examples/resampling-audio/main.go +++ b/examples/resampling-audio/main.go @@ -78,7 +78,7 @@ func main() { } dstFilename := os.Args[1] - dstFile, err := os.OpenFile(dstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + dstFile, err := os.OpenFile(dstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open destination file %s\n", dstFilename) os.Exit(1) diff --git a/examples/scaling-video/main.go b/examples/scaling-video/main.go index 5434810..19a1dae 100644 --- a/examples/scaling-video/main.go +++ b/examples/scaling-video/main.go @@ -57,7 +57,7 @@ func main() { os.Exit(1) } - dstFile, err := os.OpenFile(dstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + dstFile, err := os.OpenFile(dstFilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", dstFilename) os.Exit(1) diff --git a/examples/vaapi-encode/main.go b/examples/vaapi-encode/main.go index fabd7e3..c88114f 100644 --- a/examples/vaapi-encode/main.go +++ b/examples/vaapi-encode/main.go @@ -94,12 +94,12 @@ func main() { } size = width * height - fin, err = os.OpenFile(os.Args[3], os.O_RDONLY, 0666) + fin, err = os.OpenFile(os.Args[3], os.O_RDONLY, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", os.Args[3]) os.Exit(1) } - fout, err = os.OpenFile(os.Args[4], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + fout, err = os.OpenFile(os.Args[4], os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { fmt.Fprintf(os.Stderr, "Could not open %s\n", os.Args[4]) goto close